简体   繁体   中英

Issue with updating field with embedded map in orientdb

I have a javascript function in orientdb studio(2.1.12) where I am trying to update field called "node" with json whose property is of type embeddedMap in uiJson Document/Class.Find the code below:

 var dt = db.query("SELECT * from uijson");
    childUijson = dt[0].getRecord();
     node = childUijson.field('node');
     print(node )
    db.command('update uiJson set node=' + node + 'where @rid=18:1');
    return node;
       /*Print in oriendb console{0=inputs[{s_type=URL,source=,v_type=java.l,value=http://www.gmail.com}], next={0=1}, label=Open Url, type=OPEN_URL, component=FireFox, screenshot=false,chained=false,flowchartElement=startElement_1,left=0.12737921}}
*/
/*Return statement {
        "0": {
            "inputs": [
                {
                    "s_type": "URL",
                    "source": "",
                    "v_type": "java.lang.String",
                    "value": "http://localhost:8090/Automaton/"
                }
            ],
            "next": {
                "0": "1"
            },
            "label": "Open Url",
            "type": "OPEN_URL",
            "component": "FireFox",
            "screenshot": false,
            "chained": false,
            "flowchartElement": "startElement_1",
            "top": 0.4410876,
            "left": 0.12737921
        }           
        "@type": "d",
        "@version": 0
    }*/

Print and return uses the same variable node .While printing in the console it prints using java object tostring() while returning it gives as Json.Please help me in updating a field with Json of type embedded map.

Error message {
    "errors": [
        {
            "code": 500,
            "reason": 500,
            "content": "com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #0: Error parsing query: \nupdate uiJson set node={0={inputs=[{s_type=URL, source=, v_type=java.lang.String, value=http://www.gmail.com/}], next={0=1}, label=Open Url, type=OPEN_URL, component=FireFox, screenshot=false, chained=false, flowchartElement=startElement_1, top=0.4410876, left=0.12737921}}where @rid=18:1\nEncountered \" <INTEGER_LITERAL> \"0 \"\" at line 1, column 25.\r\nWas expecting one of:\r\n    <TO> ...\r\n    <VALUES> ...\r\n    <SET> ...\r\n    <ADD> ...\r\n    <PUT> ...\r\n    <MERGE> ...\r\n    <CONTENT> ...\r\n    <REMOVE> ...\r\n    <ORDER> ...\r\n    <GROUP> ...\r\n    <OFFSET> ...\r\n    <RECORD> ...\r\n    <LUCENE> ...\r\n    <NEAR> ...\r\n    <WITHIN> ...\r\n    <EXCEPTION> ...\r\n    <FIND> ...\r\n    <REFERENCES> ...\r\n    <RECORD_ATTRIBUTE> ...\r\n    <CHARACTER_LITERAL> ...\r\n    <STRING_LITERAL> ...\r\n    \"}\" ...\r\n    <IN> ...\r\n    <KEY> ...\r\n    <IDENTIFIER> ...\r\n    <QUOTED_IDENTIFIER> ...\r\n    "
        }
    ]
}
childUijson.field("node",node);
db.save();
db.commit();

Solved my problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM