mongoose 查询
发布于 2小时前 作者 wjy4124 105 次浏览 来自 问答

现有数据 collection1: {id:1,name:"a",age:12} {id:2,name:"b",age:123} {id:3,name:"c",age:1234}

collection2: (group中的为collection1中的id) {id:1,name:"lol",group:[1,3]} {id:2,name:"lol2",group:[1,2,3]} {id:3,name:"lol3",group:[2,3]}

想查得collection2中id=2的数据 并为此格式 {name:"lol2",group:[“a","b","c”]} {name:"lol2",group-names:[“a","b","c”]} //这样更好… 求大神支招

本人用populate 只能返回 {name:"lol2",group:[{name:"a"},{name:"b"},{name:"c"}]}

回到顶部