Error Unsupported projection option: $project "code":2,"Codename":"Badvalue"

Asked

Viewed 290 times

0

I’d like to search where I want only the records where watson is equal to true and node-visited is equal to Bem-vindo

Documento no Mongo

I was doing it this way

db.getCollection('conversations').find({'watson':true},
{    
$project: 
{
    messages: 
    {
        $filter: 
        {  
            input: '$messages',
              as: 'message',
            cond: 
            {
                $eq:['$$message.output.nodes_visited','Bem-vindo']
            } 
        }
    }
}
})

But it did not work and gave the following error

Error: error: {
"ok" : 0,
"errmsg" : "Unsupported projection option: $project: { messages: { $filter: { input: \"$messages\", as: \"message\", cond: { $eq: [ \"$$message.output.nodes_visited\", undefined ] } } } }",
"code" : 2,
"codeName" : "BadValue"
}
  • I identified the error, the $filter only works with Aggregate db.getCollection('conversations').aggregate({$match:'watson':true},, but it’s still not filtering right

1 answer

0

I identified the error, the $filter only works with Aggregate db.getCollection('conversations').aggregate({$match:'watson':true}, but it’s still not filtering right

Browser other questions tagged

You are not signed in. Login or sign up in order to post.