比如其中一条记录的一个字段是info:[{gh:001,name:'张三',age:24},{gh:002,name:'李四',age:24},{gh:003,name:'小明',age:24}] ,怎么能以 李四的gh,检索到002呢。望大神指点
比如其中一条记录的一个字段是info:[{gh:001,name:'张三',age:24},{gh:002,name:'李四',age:24},{gh:003,name:'小明',age:24}] ,怎么能以 李四的gh,检索到002呢。望大神指点
2 个回答
db.collection('todos').where({ info: _.elemMatch({ name: _.eq('李四') }) }) .get() db.collection('todos').where({ 'info.name': '李四' }) .get()
aggregate.unwind
where({'info.name':'李四'})