I am trying to solve Lab 1 and writing query but mongoDB is throwing this error

I am trying to solve Lab 1 and writing query with my best understanding but mongoDB is throwing this error. I dont know what is wrong? Am I making syntax mistake or other. Please guide me.
Query
db.movies.aggregate([< deleted >]).pretty()

Error
2019-03-19T09:24:36.259+0500 E QUERY [js] Error: command failed: {
“operationTime” : Timestamp(1552969474, 1),
“ok” : 0,
“errmsg” : “unknown operator: $and”,
“code” : 2,
“codeName” : “BadValue”,
“$clusterTime” : {
“clusterTime” : Timestamp(1552969474, 1),
“signature” : {
“hash” : BinData(0,“k0D5N6PrUiJa6RSnsU6eCv2X0XM=”),
“keyId” : NumberLong(“6627672121604571137”)
}
}
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:18:14
_assertCommandWorked@src/mongo/shell/assert.js:536:17
assert.commandWorked@src/mongo/shell/assert.js:620:16
DB.prototype._runAggregate@src/mongo/shell/db.js:260:9
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1062:12
@(shell):1:1

Waiting to read kind response from senoirs
Sulaiman

Please follow forum guidelines and do not post potential answers. Error messages are sufficient most of the time.

The error message indicates that ‘$and’ is an unknown operator. But we all know it is one. This means you are using it at the wrong place. Since you use $and in two places, it is hard to know which one is wrong. Make your pipeline simpler until you can pinpoint which $and is the culprit and then you can go on and fix it.

First, because of all the curly braces required by Mongo, it’s very easy to make syntactical errors. I stopped using the Mongo shell as a result and now use NoSQLBooster. It’s free and really helps minimize errors in complex queries.

As @steevej-1495 indicated, your second $and is the issue. I suggest looking at the $in operator. Don’t forget that $in looks for an array e.g. { $in: ["thing1", "thing2"] } not another object { $in: {"thing1", "thing2"} }.

@Charlie_34553

It’s great that you want to help – and your advice is good – but please follow Forum guidelines and do not post (or re-post :slightly_smiling_face: ) code here. Thanks.

I hit “Reply”. The original poster’s code was included automatically. Unregistered.

PS. You have yet to redact the original poster’s code.

@Charlie_34553

Well… some days are better than others – and then there are days I don’t appear to be paying attention at all. Thanks. :blush: