为什么Meteor使用光纤而不是promises或async或者可能是异步调用?什么是纤维的好处?有人可以解释这个架构决策吗?
$facet从 3.4 开始在 mongo 中有聚合阶段 - 这很酷。它允许在同一组输入文档的单个阶段内处理多个聚合管道。
但是它不允许在另一个中使用一个 $facet。引用:“任何其他聚合阶段也可以与 $facet 一起使用,除了:$facet、$out、$geoNear、$indexStats、$collStats”
有人明白原因吗?
我只想这样使用 $facet:
db.collection.aggregate([{
$facet: {
'first': [
$facet: { // here is the sub $facet
'subFirst1': [],
'subFirst2': []
}
],
'second': [
//...
]
}
}])
Run Code Online (Sandbox Code Playgroud)
这应该产生一个文档,如:
{
first: {
subFirst1: {...},
subFirst2: {...}
},
second: {...}
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试这个它会抛出错误:
specified stage is not allowed to be used within a $facet stage: 0: { $facet: { subFirst1: [ ... ] } }"
Run Code Online (Sandbox Code Playgroud) 我们的想法是将一种行号返回给mongodb聚合命令/管道.与我们在RDBM中的情况类似.
它应该是唯一的数字,如果它与行/数字完全匹配则不重要.
对于像这样的查询:
[ { $match: { "author" : { $ne: 1 } }} , { $limit: 1000000 } ]
Run Code Online (Sandbox Code Playgroud)
回报 :
{ "rownum" : 0, "title" : "The Banquet", "author" : "Dante", "copies" : 2 }
{ "rownum" : 1, "title" : "Divine Comedy", "author" : "Dante", "copies" : 1 }
{ "rownum" : 2, "title" : "Eclogues", "author" : "Dante", "copies" : 2 }
{ "rownum" : 3, "title" : "The Odyssey", "author" : "Homer", "copies" : 10 …Run Code Online (Sandbox Code Playgroud)