-
Notifications
You must be signed in to change notification settings - Fork 21
managing multiple documents from db #9
Comments
You have to Query them by _id. F.e. use the first({}) method to get the first document and then use the auto generated _id field to update/delete. |
Thanks for the response. is it possible to have say eg: and I want to do db.insert with |
You have to strip the last comma, wrap the response in json array brackets and replace single quotations marks with double quotations marks f.e. [
{"name": {"first": "Alex", "last": "Boyle"}, "message": "abc", "active": true },
{ "name": {"first": "Maia", "last": "Herzog"}, "message": "def", "active": true }
] Now you can jsonDecode the string and insert the data with db.insertMany(data) |
I get this error when I tried. |
Could you please post the "print(data)" of the object you try to insert? |
This is the decoded data from HTTP response.body, then I try to insert into db
|
Try something like this: var data = List<Map<dynamic, dynamic>>.from(jsonDecode(jsonData));
db.insertMany(data); |
this worked, thanks, you are awesome |
Hi I Have two different documents in the db:
document 1
{
"userData" : {
"id":"16",
"phone_number":"+233247832697",
"first_name":"Michael",
"last_name":"Sowah",
"username":"mtsowah"
},
token: "9a647851935d03bbc87e25cef1bba0089efabcb1"
}
document 2
{
{
"id":"1",
"title":"Amazing! collection",
"entity":"Amazing! collection","location":"Accra, Ghana",
"description":"Amazingingly beautifull and quite affordable quality jeans..",
"category":"Fashion",
"type_id":"1",
"reaction":"praise",
"user_id":"2",
"fullname":"James Bond",
"username":"jamesbond007"
},
{
"id":"2",
"title":"collection",
"entity":"Amazing! collection","location":"Accra, Ghana",
"description":"Amazingingly beautifull and quite affordable quality jeans..",
"category":"Fashion",
"type_id":"1",
"reaction":"praise",
"user_id":"2",
"fullname":"James Bond",
"username":"jamesbond007"
}
}
The text was updated successfully, but these errors were encountered: