我想制作一个python脚本,根据来自另一个集合public
中一个字段的匹配,向我的teachers
集合中的对象添加一个新字段。
我的public
mongo集合看起来像:
{
_id: 'a1',
title: 'title stuff one',
br_code: ['M333','L9876'],
},
{
_id: 'a2',
title: 'title stuff two',
br_code: ['L9876','PR345'],
}
我的teachers
mongo集合看起来像:
{
_id: 'b1',
br_code: ['M333','L9876'],
br_code: ['unknown label','lunch time guidelines'],
},
{
_id: 'b2',
br_code: ['PR345'],
br_label: ['children art book']
},
{
_id: 'b3',
br_code: ['L1234','L9876'],
br_label: ['this is a label','lunch time guidelines']
}
我在public
中所需的更新如下:
{
_id: 'a1',
title: 'title stuff one',
br_code: ['M333','L9876'],
br_label: ['unknown label','lunch time guidelines']
},
{
_id: 'a2',
title: 'title stuff two',
br_code: ['L9876','PR345'],
br_label: ['lunch time guidelines', 'children art book']
}