how to update data subdocument array mongodb

Solutions on MaxInterview for how to update data subdocument array mongodb by the best coders in the world

showing results for - "how to update data subdocument array mongodb"
Liam
01 Jan 2020
1// mongodb operation
2db.getCollection('profilesservices').update({
3  _id: ObjectId("6037ad8ac8f713f1d31abe38"), 
4 "workExperience._id": ObjectId("6037ad8ac8f713f1d31abe39")}, 
5   { $set: { "workExperience.$.companyName": "bukalapak" }
6   
7})
8
9
10//sample data
11}
12    "profileId" : "Sa4Dq9Xuw",
13    "photo" : "https://res.cloudinary.com/coding-street-art/image/upload/v1614261651/yxnvpazindsvz6lfst3m.jpg",
14    "gender" : "pria",
15    "birthDate" : ISODate("1997-03-19T17:00:00.000Z"),
16    "status" : "mahasiswa",
17    "nationality" : "indonesia",
18    "aboutMe" : null,
19    "resume" : "https://res.cloudinary.com/coding-street-art/raw/upload/v1614261653/bemkbknvhzknxffmala2.doc",
20    "skills" : [ 
21        "javascript", 
22        "typescript", 
23        "react", 
24        "vuejs", 
25        "express.js", 
26        "nodejs"
27    ],
28    "userId" : "602e8f43c0e227e6cb80bc56",
29    "workExperience" : [ 
30        {
31            "companyName" : "bukalapak", //before value is bukopin
32            "jobPosition" : "data entry",
33            "startDate" : ISODate("2015-02-14T17:00:00.000Z"),
34            "endDate" : ISODate("2017-07-27T17:00:00.000Z"),
35            "workInformation" : "",
36            "_id" : ObjectId("6037ad8ac8f713f1d31abe39")
37        }, 
38        {
39            "companyName" : "procar international finance",
40            "jobPosition" : "general affair",
41            "startDate" : ISODate("2015-02-14T17:00:00.000Z"),
42            "endDate" : ISODate("2017-07-27T17:00:00.000Z"),
43            "workInformation" : "",
44            "_id" : ObjectId("507f1f77bcf86cd799439011")
45        }
46    ],
47    "education" : [ 
48        {
49            "institutionName" : "unindra",
50            "educationDegree" : "sarjana",
51            "fieldStudy" : "tehnik informatika",
52            "startDate" : ISODate("2015-03-24T17:00:00.000Z"),
53            "endDate" : ISODate("2020-03-24T17:00:00.000Z"),
54            "educationInformation" : "",
55            "_id" : ObjectId("6037ad8ac8f713f1d31abe3a")
56        }
57    ],
58    "appreciation" : [],
59    "volunteerExperience" : [],
60    "__v" : 0
61}
queries leading to this page
update array in mongo docusing element from array in update mongodbmongodb update with arrayupdate array document mongodbhow to update array element in mongodbmongodb update array itemupdate array in mongodbupdate array in document mongodbhow to update data inside an array in mongodbhow to update an array in mongodb 3fmongodb update array elementmongodb update all array elementsupdate subdocument array mongodbhow to update the existing array with array in mongodbmongodb how to update sub arrayhow to update an array in mongodbhow to update array in mongodbmongodb update subdocument arrayupdate subdocument in array mongodbupdate nested document array mongodbupdate array element mongodbupdate a student from array in mongodbmongodb update query array with objectshow to run update query on array in mongodbupdate array of subdocument mongodbmongod update arrayi got a array of data i want to update all at once using mongodbupdate element in array at index mongodbmongodb update document array of objectsmongodb update java library subdocument arrayhow to update an element of array in mongodbmongodb update array subdocumenthow to update embedded arrays in mongo db 3fupdate elements in array mongodbupdate mongodb arraymongodb update all elements in arraymongodb update the first subdocument in arrayhow to update all documents with a array in mongomongodb update all sub document in arraymongodb update sub document arrayhow to update data subdocument array in mongodbhow to update a subdocument in an array mongodbupdate query in mongo to update arrayhow to update data subdocument array mongodbmongodb update objects in a document 27s arraymongodb update array of documentsmongodb update sub array elementmongodb update subdocument array elkementget array data and update one by one in mongodbmongodb update document array objectmongodb update subdocument array httpupdate item in array of strings mongodb embedded documentmongodb update document with arrays using arrayfiltermongodb update arrayupdate data subdocument array mongodbmongodb update query for an array elementupdate all arrays elements under a document mongoupdate mongo document array stringupdate embedded array mongodbhow to update an array from the existing array in mongodbmongodb query and update arraymongodb embedded array updateupdate element in array mongodbmongodb update from arrayset update array mongodbupdating array mongodbmongodb update sub array objechow to update array element of mongodb objectupdate data subdocument array in mongodbmongodb update document with arraysarray element update mongodbhow to update array inside array in mongodbmongodb update all the value of embedded document in array c 23mongodb array of document update partialhow to update array of objects in mongodbhow to update data subdocument array mongodb