如何在猫鼬中使用.slice [英] How to use .slice in mongoose

查看:82
本文介绍了如何在猫鼬中使用.slice的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中找到了它

I got this in my app

...
Score.find({ match: {$in: ids}} )
     .sort([[score_sort, 'descending']])
     .slice([skip, limit])
     .exec(function(err, scores) {
    if (err || !scores) {
        throw err;
    } else {
        // do something cool
    }
});

但是使用slice操作时出现错误,错误是:

But I get an error using the slice operation, the error is:

Error: slice() must be used after where() when called with these arguments

我尝试将.find替换为.where,但仍然出现相同的错误.有人知道如何解决这个问题吗?

I have tried to replace .find with .where but I still get the same error. Anyone knows how to fix this?

推荐答案

...

Score.find({ match: {$in: ids}} )
     .sort([[score_sort, 'descending']])
     .skip(skip)
     .limit(limit)
     .exec(function(err, scores) {
    if (err || !scores) {
        throw err;
    } else {
        // do something cool
    }
});

这篇关于如何在猫鼬中使用.slice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆