Error query mongoose

-1

I have a query in NodeJS with MongoDB:

filter:['abertos','cancelados'];

schemas.chamados
    .find({STATUS_CHAMADO : {"$in" : filter}})
    .exec(function(err, dados) {
        if(err) return callback(err);
        else {
            return callback(dados);
        }
    });

Displays the following error:

Object {message: "Cast to string failed for value "undefined" at path "STATUS_CHAMADO"", name: "CastError", type: "string", path: "STATUS_CHAMADO"}

Does anyone know what it can be?

When the user selects the filter on the angled front end, the node would look for these values.

    
asked by anonymous 03.03.2015 / 20:03

1 answer

1

As Caputo said, you only convert% of% to% with% as follows:

var arr = Object.keys(filter).map(function(k) { return filter[k] });
    
04.03.2015 / 12:34