【发布时间】:2019-05-22 20:52:10
【问题描述】:
我想知道如何获取特定的字段值?
在我的mysql中:
select *,
(select count(qty) from score where id = a.id) as d_qty
from mlbhitters as a order by no desc
在我的猫鼬中:
this.aggregate([
{
$match:options.query
},
{
$sort:{
no:-1
}
},
{
$limit:options.limit
}
]).exec(callback);
这就是我应该在我的猫鼬中插入子查询的地方吗?
(select count(qty) from score where id = a.id) as d_qty
我很难理解 MongoDB 是如何工作的 :(
【问题讨论】:
标签: javascript database mongodb mongoose