How to update mongodb collections

My collection structure:

col1 = {'class':'12', 'roll':[1, 2, 3, 4]}

Now i want a updatecollection col1in

col1 = {'class':'12', 'roll':[1, 2, 3, 4, 5]}

I added another roll number here, How to update this collection in pymongo.

+3
source share
1 answer
 db.col1.update( { class : 12}, { $push : { roll : 5 } } )
+3
source

Source: https://habr.com/ru/post/1770480/


All Articles