Problem with Lab $match : validateLab1(pipeline)

Hi! i composed the pipeline and i had the correct result, but now these are the problems that i have:

in the directory where i i saved the validateLab1.js, i run

> MongoDB Enterprise > load('validateLab1.js')

true

so i save in pipeline the aggregation.

now i run this and it hung up :
validateLab1(pipeline)

nothing happens…

Please help me!

I resolved, i did a mistake.

i run the connection to the cluster in other terminal window.

So now i did this :

in the directory where i saved the validateLab1.js i run the command :

mongo "mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/aggregations?replicaSet=Cluster0-shard-0" --authenticationDatabase admin --ssl -u m121 -p aggregations --norc

then :

load('validateLab1.js')

then i saved the aggregation in var pipeline

at the end

validateLab1(pipeline)

@ Alessandro_65603

Please follow Forum guidelines and do not post answers or code examples here. I have edited your post accordingly. And glad you figured it out. Thanks.

Hi Guys,
Thank you for the guidelines about running Mongo from the same folder where we have saved the handouts.
In the explanation it wasn’t clear
Not everyone is a sysAdmin :wink:

Cheers,
Nico

Hi,
i was following the same way of execution as you mentioned. but I’m getting the error as shown in attachment

Hi,

problem solved.

the error “You aren’t returning the correct number of documents” was due the $count function was included in “pipeline”. after removing from pipeline it worked well
:slight_smile: :slight_smile: :slight_smile:
Thanks

1 Like