假设我的mongodb数据库看起来像这样:
{'first': ['first_one', 'first_second', 'needed_to_be_updated'], '_id': ObjectId('5adb633bc54d2d035d15169c')}
我希望:
{'first': ['first_one', 'first_second', 'updated_now'], '_id': ObjectId('5adb633bc54d2d035d15169c')}
我想通过index_no更新值,嵌套
data={'first':['first_one','first_second','needed_to_be_updated']}
index_no=2
from pymongo import MongoClient
client = MongoClient()
client = MongoClient('mongodb://localhost:27017/')
db = client.test_database
db = client['new_tagger_one']
posts = db.posts
post_id = posts.insert_one(data).inserted_id
print(posts.find_one())
posts.update_one({'first':??})