Answer the question
In order to leave comments, you need to log in
How to order documents in mongodb by field?
There are two bases. In each entry like
[{'name':'Andrey Doncov', 'inner_id': 'and_d'}, {'name':'Denis Popov', 'inner_id': 'den'}]
I need to merge them into one and sort by the id field. (This field needs to be added) I wrote the following coden_id =0
for cv in cvs:
cv['id'] = n_id
main_collection.update_one({'inner_id': cv['inner_id']}, {'$set': cv}, upsert=True)
n_id += 1
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question