Closed germancmartinez closed 5 years ago
when message payload is an array, each array element is interpreted as a parameter to the selected operation. eg when operation= "update"
, message.payload=[{surname:"smith"}, {"surname":"Smith"}, {"multi":true}]
since for you are wanting to supply an array as a single parameter, you should wrap it in a second array:
message.payload=[[1,2,3,4]]
and not message.payload=[1,2,3,4]
when message payload is an array, each array element is interpreted as a parameter to the selected operation. eg when
operation= "update"
,message.payload=[{surname:"smith"}, {"surname":"Smith"}, {"multi":true}]
since for you are wanting to supply an array as a single parameter, you should wrap it in a second array:
message.payload=[[1,2,3,4]]
and notmessage.payload=[1,2,3,4]
Thanks!
for insertMany ✗ msg.payload = [ { "name" : "Luffy" , "value" : 1} , { "name" : "Zoro" , "value" : 2 } ] ✓ msg.payload = [ [ { "name" : "Luffy" , "value" : 1} , { "name" : "Zoro" , "value" : 2 } ] ]
this is the correct format db.collectionname.insertMany([ {} , {} , {} ])
collectionname would be your collection u have created in ur database
{ } inside this your objects would be there eg:
try { db.products.insertMany( [ { _id: 13, item: "envelopes", qty: 60 }, { _id: 13, item: "stamps", qty: 110 }, { _id: 14, item: "packing tape", qty: 38 } ] ); } catch (e) { print (e); }
refer this
Hi,
I´m having problems with the InsertMany method. I´m getting the error "MongoError: docs parameter must be an array of documents". I have tried putting the document array in the msg.payload and msg.payload.docs, but I'm always getting this error. Any help is welcome! Thanks!