-1
私はPyMongoを使用していますが、このようなオブジェクトの配列であるフィールドを持つコレクション内のドキュメントを持っています。最後に要素を追加するコレクション内の埋め込みドキュメントを更新する
{
"_id" : ObjectId("509df76fbcf1bf5b27b4a23e"),
"field1" : "asfasfdas",
"field2" : "asfasdfa",
"embedded" : [
{ "field1" : "asdfasdf", "field2" : "asdfasdfa" },
{ "field1" : "asdfasfth.", "field2" : "asdfasf" }
]
}
したがって、embedded
フィールドに新しいオブジェクトを追加したいと思います。どのような方法でこれを達成できますか?
[ 'update_one'](http://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection。 update_one)または['update_many'](http://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.update_many)を実行します。また、['$ push'](https://docs.mongodb.com/manual/reference/operator/update/push/)オペレータ – styvane
が必要ですか? – provola