Initialize Database Modules

const worqhat = require('worqhat');

var config = new worqhat.Configuration({
    apiKey: "your-api-key",
    debug: true,
    max_retries: 3,
});

worqhat.initializeApp(config);

let db = worqhat.database();

Update Document data

To update some fields of a document without overwriting the entire document, use the following language-specific update() methods:

You can pass in the new data as a JSON object to the update() method. The update() method will merge the new data with the existing data in the document.

db.collection('NodeJSDb1').doc('de79272c-2ed3-46d9-ae93-ff195364466e').update({
    name: "ABC",
}).then((response) => {
    console.log(response);
}).catch((error) => {
    console.log(error);
});

Update Nested JSON Data in a Document

To replace the entire nested JSON object

To replace the entire nested JSON object, use the update() method and pass in the new nested JSON object as the value of the key you want to update.

db.collection('NodeJSDb1').doc('de79272c-2ed3-46d9-ae93-ff195364466e').update({
    key: {
        g: "h",
        i: "j",
        k: "l"
    }
}).then((response) => {
    console.log(response);
}).catch((error) => {
    console.log(error);
});