"$ in"有什么问题?在猫鼬 [英] What's wrong with "$in" in mongoose

查看:91
本文介绍了"$ in"有什么问题?在猫鼬的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.我在使用猫鼬时遇到了一个奇怪的错误

Good day for everyone. I have a strange error working with mongoose

module.js:437
  var compiledWrapper = runInThisContext(wrapper, filename, tru
                        ^
SyntaxError: Unexpected token .
    at Module._compile (module.js:437:25)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (E:\Dropbox\Dropbox\FCP\server.js
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)

我猜它是从那里来的

dbQueries.remove({_id: {$in: {req.body.data}}, authorId: req.user._id}, function onRemoveSomething(err){
            if(err) {
                res.json({epicFail: 'ERR_RestrictedAccess'});
                return; 
            }
        });

所以,我不知道怎么了.

So, I have no idea what is wrong.

推荐答案

$ in 接受数组,而不是格式无效的javascript对象

$in takes an array, not an invalidly formatted javascript object

{_id: {$in: [req.body.data]}

,或者如果req.body.data已经是数组,则省略包装[ ]

or if req.body.data is already an array, omit the wrapping [ ]

这篇关于"$ in"有什么问题?在猫鼬的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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