MongoDB Commands On Operators

Share via:

MongoDB Commands On Operators

To create a collection called student data.

To get all the documents in a collection called student data without any filter.

To get all the documents whose total marks is equals to 560.

To get all the documents whose total marks is not equals to 560.

To get all the documents whose total marks is greater than 500.

To get all the documents whose total marks is less than 550.

To get all the documents whose total marks is less than or equals to 520.

To get all the documents whose total marks is greater than or equals to 520.

To get all the documents whose total marks is present in given array of values.

To get all the documents whose total marks is not present in given array of values.

To get all the documents which satisfy both the given conditions, i.e., total marks greater than 550 and has two siblings.

To get all the documents which satisfy any one of the given conditions, i.e., total marks less than 560 or has two siblings.

To get all the documents which do not satisfy both the given conditions, i.e., total marks greater than 560 and has two siblings.

To get all the documents which is having the total marks field value less than 500, this includes the documents which do not have the total marks field.

To get all the documents which do not have the field name called “siblings.”

To get all the documents which is having the field name called “name.”

To get all the documents whose datatype of the field “siblings” is an integer.

To get all the documents whose datatype of the field “name” is a string.

To get all the documents that has a array field whose array size is exactly two.

To get the total marks which are divisible by 10, first parameter in mod is the number you want to divide by, the second one is the remainder.

To create a text index on the name field

After creating the text index on the field, you can use it for search, in this case this want to search the name antony.

To validate the schema that you need and store it in the variable called myschema.

To get all the documents that matches with the schema mentioned above.

Another way to get all the documents that matches with the schema.

To get all the documents that didn’t match with the specified above schema.

To get only the first two values of the array field called favsports.

 

Author    : Teja
LinkedIn : https://www.linkedin.com/in/teja-sai-nadh-reddy-tatireddy-048882201
Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates
KTExperts is always active on social media platforms.
Facebook  : https://www.facebook.com/ktexperts/
LinkedIn    : https://www.linkedin.com/company/ktexperts/
Twitter       : https://twitter.com/ktexpertsadmin
YouTube   :  https://www.youtube.com/c/ktexperts
Instagram  : https://www.instagram.com/knowledgesharingplatform
Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

Add Comment