【问题标题】:Is there a way to call 'distinct' through monk?有没有办法通过和尚来称呼“与众不同”?
【发布时间】:2015-01-28 23:13:08
【问题描述】:

我想在我的 node.js 服务器上执行以下“查询”:

MongoDB:

db.example.distinct('field')

预期结果:[value1, value2, ..., etc]

我试过这个 Javascript,但它不起作用:

db.get('example').distinct('field', function (err, array){...});

但我认为僧侣没有定义这种方法。 有没有办法做到这一点?

【问题讨论】:

    标签: javascript node.js mongodb monk


    【解决方案1】:

    它已被添加到和尚。 这是commit

    这是签名

    Collection.prototype.distinct = function (field, query, fn) {}
    

    您使用的是最新版本吗?

    【讨论】:

    • 看来我的更新落后了。但是...从我构建的 package.json 和我刚刚从您的链接下载的那个,版本都说 0.7.1...
    • @GoldfishGrenade 是的,这在 node.js 社区中是一个巨大的问题。我一直看到项目添加新功能而不更新其版本号。
    • 他们是否有区分排序的规定?在 mongo 中,您可以链接 .sort()
    猜你喜欢
    • 1970-01-01
    • 2019-09-18
    • 1970-01-01
    • 2020-07-12
    • 1970-01-01
    • 2017-06-19
    • 2019-10-17
    • 2016-09-22
    • 2013-05-10
    相关资源
    最近更新 更多