Azure / azure-cosmosdb-js-server

The JavaScript SDK for server-side programming in Azure Cosmos DB
MIT License
179 stars 152 forks source link

update.js Not Working with REST API #12

Open alohaninja opened 7 years ago

alohaninja commented 7 years ago

For update.js to work, I had to add JSON.parse() or the object would never turn into JS properties. update.$inc etc. would not be present. Once JSON parameter is parsed it worked great!

if (!update) throw new Error("The update is undefined or null.");
update = JSON.parse(update); // convert JSON string to object

Sample Increment HTTP Request Body...

["foo", "{\"$inc\":{\"counter\":1}}"]