I used find to get all the data in the whole table. I only want to operate one field (i.e. add, delete, modify and check one field).
Json data is as follows
{
"date": "20171123",
"stories": [
{
"images": "1.jpg",
"title": "Title 1"
},
{
"images": "2.jpg",
"title": "Title 2"
},
{
"images": "3.jpg",
"title": "Title 3"
}
],
"top_stories": [
{
"top_images": "top1.jpg",
"top_title": "top1"
},
{
"top_images": "top2.jpg",
"top_title": "top2"
},
{
"top_images": "top3.jpg",
"top_title": "top3"
}
]
}
I just want to get the data in the field stories. how should I write it?
> db.a.find({},{stories:1,_id:0}) {"stories": [{"images": "1.jpg", "title": "title 1" }, {"images": "2.jpg", "title": "title 2" }, {"images": "3.jpg", "title": "title 3"}]} > db.a.update ({}, {$ push: {stories: {"images": "4.jpg", "title": "title 4"}}}})