Node: How to store JSON Array in google datastore -
i'm trying store following object in google datastore using nodejs returning 400 "bad request" error
{ "_id":{ "$oid":"567e9e80067de880273095e0" }, "name":"windows 10", "desc":"this test", "isselfpaced":true, "credit":[ { "_id":"56640d4926b67c201b861cde", "username":"akash", "displayname":"gupta", "email":"yesitsakash@gmail.com", "role":"author" } ], "video":{ "type":0, "videokey":"khatemotionalfulls_lowb84c0084-836c-008c-a850-328687e23d02.mp4", }, "structure":4, "category":"test2", "subcategory":"dfdfdf", "content":[ { "id":"a053915c-8d10-4aa8-b464-c8a99154c3af", "name":"module 1", "type":1, "topics":[ "test1", "test2" ], "children":[ { "id":"46f18a1a-6653-41cb-be5c-002200170bb9", "name":"unit 1", "type":2, "subtype":"1", "video":{ "type":0, "videokey":"vid-20150920-wa0017ee56049d-2b08-aeb5-9b9c-b5188b1f7324.mp4", }, "note":"<ul><li><b>this test<\/b><\/li><\/ul>", "isselfpaced":true }, { "id":"da4f53a3-7ea2-4fa8-9d48-4d7199a3450c", "name":"quiz 1", "type":2, "subtype":3, "questions":[ { "question":"new question", "options":[ { "text":"option 1", "correct":true } ] } ], "isselfpaced":true } ], "time":3, "isselfpaced":true, "desc":"this test" } ], "createdby":{ "displayname":"gupta", "id":"56640d4926b67c201b861cde" }, "createdat":{ "$date":"2016-01-10t17:51:15.635z" }, "startdate":"1970-01-01t00:00:00.000z", "enddate":"1970-01-01t00:00:00.000z", "ispublish":true }; datastore.insert('test2','test2',data,function(err,key){ if(err){ res.status(500).end(); } else{ res.send(key); } }); });
nodejs code:
var keyobject = dataset.key({ namespace: namespace, path: [collectionname,utility.getguid()] }); dataset.save({key:keyobject,data:data,method:'insert'},function(err) { if(err){ callback(err,null); } else{ callback(null,keyobject.path[1]); } });
simpler scenario wirking how can store json array in google datastore using nodejs
the issue json payload malformed.
Comments
Post a Comment