我有一个健身锻炼数据库,其中包含一些力量练习。由于一项练习可以通过多种方式完成,因此我添加了一项基础练习
即_id:"BenchPressBothHands"
和几个类似的练习,即_id:"BenchPressRightHand"
,derivedFrom:"BenchPressBothHands"
是否可以将文档中已存在的键以外的所有内容都从发件人_id:"BenchPressBothHands"
复制到_id:"BenchPressRightHand"
?
伪代码:
for documents in col.find():
derivedFrom = documents.get('derivedFrom')
if derivedFrom is not None:
update document with everything from the derivedFrom-document except the keys which already exists.