M121 Lab 1 need help, error on validate script

I’m creating the aggregation in the variable ‘pipeline’, and that seems to work. I run my $match statement, and then if I type in pipeline at the prompt, it gives me all the movies in the result set. But then when I try to run validateLab1.js, it gives me the error message below. I don’t know what I’m doing wrong, please help!


MongoDB Enterprise Cluster0-shard-0:PRIMARY>
command failed: {
“operationTime” : Timestamp(1569003503, 1),
“ok” : 0,
“errmsg” : “A pipeline stage specification object must contain exactly one field.”,
“code” : 40323,
“codeName” : “Location40323”,
“$clusterTime” : {
“clusterTime” : Timestamp(1569003503, 1),
“signature” : {
“hash” : BinData(0,“ImJ5NRejvHnZ8xtHY5I5hMOMR9M=”),
“keyId” : NumberLong(“6698341139830800385”)
}
}
} : aggregate failed
MongoDB Enterprise Cluster0-shard-0:PRIMARY>

I found another item on the discussion boards that helped me figure this out. I did search before I entered this question, but didn’t find the helpful item until I searched again.

FYI–SYNTAX FOR LABS NEEDS TO BE CLEAR!!! My only problem was that I didn’t get the syntax for the variable assignment right. THIS HAPPENS TOO OFTEN IN THESE CLASSES, please make changes to make it more clear how to do what you’re asking for, or at least how to look it up! Thanks!

try this:
var pipeline = [{$match:{…}}]
– enclose aggregate expression in
– do not include db.movies.aggregate

Hope you will figure it out with this hint.

1 Like

Hi Christian, thanks for responding. I did figure this out. My question, though, is what did I miss in the course materials that would have told me that we
were supposed to put the command text in the variable rather than the
command output? It just seemed reasonable to me that the pipeline should contain the output.

Hi @Ellen_75045,

Great you figured it out :clap:

Thanks for your feedback. I will definitely forward it to the concerned team and look for the ways to make it easier for the users to complete the course.

Kind Regards,
Sonali