更新时间:2023-02-19 16:11:57
您可以在查找查询中使用 select
或 projection
来仅获取 items
代码>.
You can use select
or projection
in your find query to get only items
.
试试这个:
foodtr.find({},{'item_list':1},function(err,items){
if (err) res.send(err);
res.json({
status : '200',
message:'popular items list',
data: items
});
});
{}
类似于查询条件,在这种情况下它将检索所有文档.{'item_list':1}
是告诉 mongo 只检索 item_list
数组(_id 与其他任何东西一起默认).
{}
is similar to query condition, in this case it will retrieve all the documents.
{'item_list':1}
is to tell mongo to retrieve only item_list
array(_id comes in default along with anything else).
希望这是你想要的.