【问题标题】:Multiple Mongo Projections多个 Mongo 投影
【发布时间】:2016-04-27 04:25:43
【问题描述】:

我正在从我的 Meteor 服务器运行查询,但由于某种原因,只有第一个投影正在捕获。

Users.find({"services.facebook" : {$exists : true}}, {"_id": {$nin: doNotCount}}).fetch()

只返回facebook用户(忽略{"_id": {$nin: doNotCount}}

Users.find(, {"_id": {$nin: doNotCount}}, {"services.facebook" : {$exists : true}}).fetch()

只返回不在给定数组中的用户(忽略{"services.facebook" : {$exists : true}}

从文档看来,这是可能的:

https://docs.mongodb.org/manual/reference/operator/projection/positional/

但我没有运气

【问题讨论】:

    标签: mongodb meteor


    【解决方案1】:

    查询只是第一个参数,第二个参数处理排序、限制、限制要返回的字段等...

    改为:

    Users.find({ "services.facebook" : {$exists : true}, "_id": {$nin: doNotCount }}).fetch()
    

    【讨论】:

    • 重新阅读问题...这是我概述的第一个案例;它没有捕捉到 $nin 投影
    • 仔细看大括号的位置。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-09
    • 1970-01-01
    • 2020-10-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多