のフィールドを更新するには、[0] SQLでのこのようなだけで何かを.address SQLのどちらかで作業します。ちょうどそれを私が必要とするものに合理的にするために置く。挿入と私は電子メールですべてのコレクションフィールドprofile.emailを更新したいMongoDBの
それはこのようなものですが、動作していない:
db.getCollection('users').update(
{_id: "QYoHQkTuTXnEC6Pws"},
{$set:
{'profile.email': db.getCollection('users').aggregate({$match: {_id:'QYoHQkTuTXnEC6Pws'}},
{$project: {_id:0,email: {$arrayElemAt:
['$emails.address',0]}}})
}
}
)
結果が真ではありません。
"email" : {
"_batch" : [
{
"email" : "[email protected]"
}
],
"_useReadCommands" : true,
"_cursorid" : NumberLong(0),
"_batchSize" : undefined,
"_ns" : "meteor.users",
"_db" : {
"_mongo" : {
"slaveOk" : true,
"host" : "localhost:3001",
"defaultDB" : "",
"_readMode" : "commands",
"_writeMode" : "commands"
},
"_name" : "meteor"
},
"_collName" : "users",
"_cursorHandle" : {}
}
あなたのmongoバージョンは何ですか? – sidgate
mongoのバージョンは3.4.0です – Mehr