如何编写MongoDB请求?
以下是类型文档的示例:如何编写MongoDB请求?,mongodb,Mongodb,以下是类型文档的示例: { id: 't-123' attributes: [ { id: 'a-1', type: 'INPUT' }, { id: 'a-2', type: 'SELECT', option: [ {key: 'DE', label: 'Germany'}, {key:
{
id: 't-123'
attributes: [
{
id: 'a-1',
type: 'INPUT'
},
{
id: 'a-2',
type: 'SELECT',
option: [
{key: 'DE', label: 'Germany'},
{key: 'US', label: 'United States'}
]
}
]
}
{
id: 'f-1',
type: 't-123',
values: [
{attribute: 'a-1', value: 'my random string'},
{attribute: 'a-2', value: 'DE'}
]
}
此外,我还有一个表单集合,它引用类型集合并存储来自用户的所有填充字段
以下是表单文档的示例:
{
id: 't-123'
attributes: [
{
id: 'a-1',
type: 'INPUT'
},
{
id: 'a-2',
type: 'SELECT',
option: [
{key: 'DE', label: 'Germany'},
{key: 'US', label: 'United States'}
]
}
]
}
{
id: 'f-1',
type: 't-123',
values: [
{attribute: 'a-1', value: 'my random string'},
{attribute: 'a-2', value: 'DE'}
]
}
现在,我正在尝试查询表单集合,并自动从类型集合中为类型为SELECT的字段添加choosen键/标签对象
以下是我想要的结果:
{
id: 'f-1',
type: 't-123',
values: [
{attribute: 'a-1', value: 'my random string'},
{attribute: 'a-2', value: {key:'DE', label:'Germany'}}
]
}
“所选”键/标签是什么?例如,为什么没有选择{key:US,label:“United States”}?@tomslabbaert,“selected”表示在UI中选择。选项:[{key:'DE',label:'Germany'},{key:'US',label:'United States'}{key:'IL',label:'Israel'}……其他]选择的键/标签是什么?例如,为什么没有选择{key:US,label:“United States”}?@tomslabbaert,“selected”表示在UI中选择。选项:[{key:'DE',label:'Germany'},{key:'US',label:'United States'}{key:'IL',label:'Israel'}……附加]