NodeJS SubDoc operation & Confusing Docs


#1

I am trying to build a Backend which uses NodeJS and Express to access Couchbase. So far so good, i can connect to my bucket and get docs and write new ones. My issue is with the SubDocument operation. If i look at the current Doc’s it tells me to use “import couchbase.subdocument as SD” but that does not work as it gives me a error saying the import is only avail in Type Script /ts file. As great as couchbase is the Docs are sloppy at best which is sad thing.
So my question is how do i use Subdocs with current NodeJs SDK as the import couchbase.subdocument as SD is invalid.

On another topic is there a way to update more then one element per call ? I know i can make multiple upserts before i execute them but lets say i have a customer Doc which has an Address section which i want to update, do i need to update City and Zip separatetly or can i call an

.upsert(“home_address”, {city: ‘Los Angeles’, zip: ‘90017’ }

If thats posible what will the correct format be , do i pass values a a json doc or java object ?

Thanks


#2

After looking to some more of the docs for node.js it seems the docs use code samples from php as they as the syntax looks more php like then nodeJS
It seems doc mix Python, JavaScript and PHP samples which does not make sense

https://docs.couchbase.com/nodejs-sdk/2.5/subdocument-operations.html