Bug #84547 Error when mysqlx tries to parse json object while modifying data (Nodejs)
Submitted: 18 Jan 2017 7:11 Modified: 6 Jun 2022 17:17
Reporter: Tanvi Shah Email Updates:
Status: Won't fix Impact on me:
None 
Category:Connector for Node.js Severity:S2 (Serious)
Version:Connector-Nodejs version - 1.0.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: document-store, mysql/xdevapi, NodeJS

[18 Jan 2017 7:11] Tanvi Shah
Description:
I want to update my MySQL document store schema.I am using @mysql/xdevapi for document store.I have referred this link for example <a href="http://insidemysql.com/develop-by-example-document-store-working-with-collections-using-no...">Reference Link</a>

For single field it is working properly.But when i am updating whole object it throws an error as "Provided expression is neither a expression string nor a parse tree".

Kindly suggest, is there any other way to do this.

How to repeat:
Single field syntax:-

    coll.modify("$._id == '100'").set('$.name', 'New name').set('$.description', 'New Description').execute();

This is working fine. 

Updating object : -

    var obj = {"name":"New Name"};
    coll.modify("$._id == '100'").set(obj).execute()

This is not working.
[27 Jan 2017 10:59] Chiranjeevi Battula
Hello Tanvi Shah,

Thank you for the bug report.
Verified based on internal discussion with dev's.

Thanks,
Chiranjeevi.
[6 Jun 2022 17:17] Rui Quelhas
This is more like a feature request. In any case, as of revision #84f250c,
it is possible to do what is suggested using the "patch()" method. The
"set()" method continues to operate on individual document properties only,
being fluent nonetheless (as established by the DevAPI standard).

The following examples will result in the same outcome:

var obj = {name:"Name", description:"Description"};
coll.modify("$._id == '100'").patch(obj).execute();

// or

coll.modify("$._id == '100'").set("name", "Name").set("description",
"Description").execute();

Thanks for the bug report