Professional Documents
Culture Documents
ADB_Lab sheet 2 (1)
ADB_Lab sheet 2 (1)
Lab 2 Manual
Level 1:
Experiment No. 2: Try experiments on MongoDB Operators
Level 1: Perform queries involving MongoDB Query and Projection Operators using ‘Student’
Database.
Introduction
MongoDB provides many different operators for interacting with the database.
Operators are special symbols or keywords that tell a compiler or interpreter what
mathematical or logical operations to perform.
Here we'll learn query and projection operators. So let's get going!
Query operators
The query operators extend MongoDB's capabilities by allowing developers to write
complicated queries that interact with data sets relevant to their applications.
Using the $jsonSchema with the $nor to find all documents that do not satisfy the
schema:
db.inventory.find( { $nor: [ { $jsonSchema: myschema } ] } )
c.) $meta
The meta operation delivers a response for each document that matches the query
in terms of metadata.
{ $meta: <metaDataKeyword> }
d.) $slice
This operator controls the number of values in an array that a query returns.
db.books.find( { field: value }, { array: {$slice: count } } );