0% found this document useful (0 votes)
35 views66 pages

Day6-Raw Dump of All The Commands MongoDB Commands On Last Day

The document discusses MongoDB database and collection operations like create, insert, drop, and find. It shows examples of creating databases and collections, inserting documents, dropping collections and databases. It also demonstrates querying and finding documents from collections.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views66 pages

Day6-Raw Dump of All The Commands MongoDB Commands On Last Day

The document discusses MongoDB database and collection operations like create, insert, drop, and find. It shows examples of creating databases and collections, inserting documents, dropping collections and databases. It also demonstrates querying and finding documents from collections.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 66

create database - use <database_name>

create collection - db.createCollection('<collection_name>')


insert document - db.collection_name.insert({key:value})
create collection by directly inserting document -
db.collection_name.insert({key:value})
drop collection - db.collection_name.drop()
drop database

use <database_name>
db.dropDatabase()

employee - Accountant , Librarian

--> OR condition on two different KEYS

db.Author.updateMany({},{$set:{Ccd:'IN'}})
db.Author.updateMany({Nationality:'USA'},{$set:{Ccd:'US'}})

C:\Users\G>mongo
MongoDB shell version v4.2.23
connecting to: mongodb://127.0.0.1:27017/?
compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("35551c1b-3d96-4175-8ced-babd54d816aa") }
MongoDB server version: 6.0.3
WARNING: shell and server versions do not match
Server has startup warnings:
{"t":{"$date":"2024-04-10T10:09:56.612+05:30"},"s":"W", "c":"CONTROL",
"id":22120, "ctx":"initandlisten","msg":"Access control is not enabled for the
database. Read and write access to data and configuration is unrestricted","tags":
["startupWarnings"]}

---
Enable MongoDB's free cloud-based monitoring service, which will then receive and
display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).

The monitoring data will be available on a MongoDB website with a unique URL
accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()


To permanently disable this reminder, run the following command:
db.disableFreeMonitoring()
---

> show databases


NW 0.000GB
admin 0.000GB
bomlms 0.000GB
chkidx 0.164GB
config 0.000GB
dbda 0.000GB
dellms 0.000GB
hyblms 0.000GB
lms 0.001GB
lmsblr 0.000GB
lmshyb 0.000GB
local 0.000GB
newdata 0.000GB
newhydlms 0.001GB
newlms 0.000GB
tvmlms 0.000GB
>
>
> use lmshyb
switched to db lmshyb
>
>
>
> show collections
author
>
>
>
> db.Author.find()
>
>
>
> db.author.find()
{ "_id" : ObjectId("6614ee9b0c2de379cc93e1ba"), "name" : "Chetan Bhagat", "age" :
52 }
{ "_id" : ObjectId("6614ef6c0c2de379cc93e1bb"), "name" : "Robin Sharma",
"Country" : "Canada" }
{ "_id" : ObjectId("6614efd70c2de379cc93e1bc"), "gender" : "Male", "writertype" :
"fiction", "AuthorName" : "Mukul Deva" }
>
>
>
> db.author.find().pretty()
{
"_id" : ObjectId("6614ee9b0c2de379cc93e1ba"),
"name" : "Chetan Bhagat",
"age" : 52
}
{
"_id" : ObjectId("6614ef6c0c2de379cc93e1bb"),
"name" : "Robin Sharma",
"Country" : "Canada"
}
{
"_id" : ObjectId("6614efd70c2de379cc93e1bc"),
"gender" : "Male",
"writertype" : "fiction",
"AuthorName" : "Mukul Deva"
}
>
> db.createCollection('Department')
{ "ok" : 1 }
>
>
> show collections
Department
author
>
>
>
> db.Department.insert({deptname:'HR',capacity:100})
WriteResult({ "nInserted" : 1 })
>
>
> db.department.find()
>
>
> db.Department.find()
{ "_id" : ObjectId("66161a70aacfe55304b31ac7"), "deptname" : "HR", "capacity" : 100
}
>
>
>
> db.Department.insert({deptname:'Qality',capacity:200},
{deptname:'Admin',capacity:50})
WriteResult({ "nInserted" : 1 })
>
>
> db.Department.find()
{ "_id" : ObjectId("66161a70aacfe55304b31ac7"), "deptname" : "HR", "capacity" : 100
}
{ "_id" : ObjectId("66161b0faacfe55304b31ac8"), "deptname" : "Qality", "capacity" :
200 }
>
>
>
> db.Deparment.insertMany({depatname:'Marketing',capacity:100,remark:'remote
working'},{deptname:'Finance',capacity:30})
2024-04-10T10:25:56.210+0530 E QUERY [js] uncaught exception: TypeError:
documents.map is not a function :
DBCollection.prototype.insertMany@src/mongo/shell/crud_api.js:307:17
@(shell):1:1
> db.Department.insertMany({depatname:'Marketing',capacity:100,remark:'remote
working'},{deptname:'Finance',capacity:30})
2024-04-10T10:28:36.768+0530 E QUERY [js] uncaught exception: TypeError:
documents.map is not a function :
DBCollection.prototype.insertMany@src/mongo/shell/crud_api.js:307:17
@(shell):1:1
>
>
>
> db.Department.insertMany([{depatname:'Marketing',capacity:100,remark:'remote
working'},{deptname:'Finance',capacity:30}])
{
"acknowledged" : true,
"insertedIds" : [
ObjectId("66161cafaacfe55304b31ac9"),
ObjectId("66161cafaacfe55304b31aca")
]
}
>
>
> db.Department.find().pretty()
{
"_id" : ObjectId("66161a70aacfe55304b31ac7"),
"deptname" : "HR",
"capacity" : 100
}
{
"_id" : ObjectId("66161b0faacfe55304b31ac8"),
"deptname" : "Qality",
"capacity" : 200
}
{
"_id" : ObjectId("66161cafaacfe55304b31ac9"),
"depatname" : "Marketing",
"capacity" : 100,
"remark" : "remote working"
}
{
"_id" : ObjectId("66161cafaacfe55304b31aca"),
"deptname" : "Finance",
"capacity" : 30
}
>
>
>
>
> show collections
Department
author
>
> db.location.insert({lid:'L001',city:'Mum ObjectId("66161cafaacfe55304b31ac9"),'})
WriteResult({ "nInserted" : 1 })
>
>
>
> show collections
Department
author
location
>
> db.location.find()
{ "_id" : ObjectId("66161d29aacfe55304b31acb"), "lid" : "L001", "city" : "Mum
ObjectId(\"66161cafaacfe55304b31ac9\")," }
>
>
>
> db.dropCollection('location')
2024-04-10T10:32:44.516+0530 E QUERY [js] uncaught exception: TypeError:
db.dropCollection is not a function :
@(shell):1:1
>
>
>
> db.location.drop()
true
>
>
> show collections
Department
author
>
> db.location.insert({lid:'L001',city:'Mumbai'})
WriteResult({ "nInserted" : 1 })
>
>
>
> db.location.find()
{ "_id" : ObjectId("66161dcbaacfe55304b31acc"), "lid" : "L001", "city" : "Mumbai" }
> use hyblms;
switched to db hyblms
> db.dropDatabase()
{ "ok" : 1 }
>
>
>
> show databases
NW 0.000GB
admin 0.000GB
bomlms 0.000GB
chkidx 0.164GB
config 0.000GB
dbda 0.000GB
dellms 0.000GB
lms 0.001GB
lmsblr 0.000GB
lmshyb 0.000GB
local 0.000GB
newdata 0.000GB
newhydlms 0.001GB
newlms 0.000GB
tvmlms 0.000GB
>
> use hyblms
switched to db hyblms
>
>
>
> show databases
NW 0.000GB
admin 0.000GB
bomlms 0.000GB
chkidx 0.164GB
config 0.000GB
dbda 0.000GB
dellms 0.000GB
hyblms 0.000GB
lms 0.001GB
lmsblr 0.000GB
lmshyb 0.000GB
local 0.000GB
newdata 0.000GB
newhydlms 0.001GB
newlms 0.000GB
tvmlms 0.000GB
>
> use hyblms
switched to db hyblms
>
>
> show collections
Author
>
>
>
> db.Author.find().pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f7"),
"AuthorId" : "A001",
"AuthorName" : "Thomas Friedman",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0f9"),
"AuthorId" : "A003",
"AuthorName" : "Robert Kiyosak",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0fa"),
"AuthorId" : "A004",
"AuthorName" : "Robin Sharma",
"Gender" : "M",
"Nationality" : "Canada"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f0fe"),
"AuthorId" : "A012",
"AuthorName" : "Yuval Noah Harari",
"Gender" : "M",
"Nationality" : "Israeal"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India"
}
> show collections
Author
Book
Booking
Department
Employee
Location
Member
Plan
Publisher
Rack
>
> db.Author.find()
{ "_id" : ObjectId("66162559565f33eab365f0f7"), "AuthorId" : "A001", "AuthorName" :
"Thomas Friedman", "Gender" : "M", "Nationality" : "USA" }
{ "_id" : ObjectId("66162559565f33eab365f0f8"), "AuthorId" : "A002", "AuthorName" :
"Ken Follett", "Gender" : "M", "Nationality" : "UK" }
{ "_id" : ObjectId("66162559565f33eab365f0f9"), "AuthorId" : "A003", "AuthorName" :
"Robert Kiyosak", "Gender" : "M", "Nationality" : "USA" }
{ "_id" : ObjectId("66162559565f33eab365f0fa"), "AuthorId" : "A004", "AuthorName" :
"Robin Sharma", "Gender" : "M", "Nationality" : "Canada" }
{ "_id" : ObjectId("66162559565f33eab365f0fb"), "AuthorId" : "A005", "AuthorName" :
"Stephen Hawking", "Gender" : "M", "Nationality" : "UK" }
{ "_id" : ObjectId("66162559565f33eab365f0fc"), "AuthorId" : "A006", "AuthorName" :
"Agatha Christie", "Gender" : "F", "Nationality" : "UK" }
{ "_id" : ObjectId("66162559565f33eab365f0fd"), "AuthorId" : "A007", "AuthorName" :
"Chetan Bhagat", "Gender" : "M", "Nationality" : "India" }
{ "_id" : ObjectId("66162559565f33eab365f0fe"), "AuthorId" : "A012", "AuthorName" :
"Yuval Noah Harari", "Gender" : "M", "Nationality" : "Israeal" }
{ "_id" : ObjectId("66162559565f33eab365f0ff"), "AuthorId" : "A009", "AuthorName" :
"J K Rollowings", "Gender" : "F", "Nationality" : "UK" }
{ "_id" : ObjectId("66162559565f33eab365f100"), "AuthorId" : "A008", "AuthorName" :
"Vikram Seth", "Gender" : "M", "Nationality" : "India" }
{ "_id" : ObjectId("66162559565f33eab365f101"), "AuthorId" : "A011", "AuthorName" :
"Ravi Subramainyan", "Gender" : "M", "Nationality" : "India" }
>
>
>
> db.Author.find().pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f7"),
"AuthorId" : "A001",
"AuthorName" : "Thomas Friedman",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0f9"),
"AuthorId" : "A003",
"AuthorName" : "Robert Kiyosak",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0fa"),
"AuthorId" : "A004",
"AuthorName" : "Robin Sharma",
"Gender" : "M",
"Nationality" : "Canada"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f0fe"),
"AuthorId" : "A012",
"AuthorName" : "Yuval Noah Harari",
"Gender" : "M",
"Nationality" : "Israeal"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India"
}
>
>
>
> db.Author.findOne().pretty()
2024-04-10T11:14:50.465+0530 E QUERY [js] uncaught exception: TypeError:
db.Author.findOne(...).pretty is not a function :
@(shell):1:1
>
>
>
> db.Author.findMany().pretty()
2024-04-10T11:15:45.053+0530 E QUERY [js] uncaught exception: TypeError:
db.Author.findMany is not a function :
@(shell):1:1
>
>
>
>
> db.Author.find().pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f7"),
"AuthorId" : "A001",
"AuthorName" : "Thomas Friedman",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0f9"),
"AuthorId" : "A003",
"AuthorName" : "Robert Kiyosak",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0fa"),
"AuthorId" : "A004",
"AuthorName" : "Robin Sharma",
"Gender" : "M",
"Nationality" : "Canada"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f0fe"),
"AuthorId" : "A012",
"AuthorName" : "Yuval Noah Harari",
"Gender" : "M",
"Nationality" : "Israeal"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India"
}
>
>
>
> db.Author.find({},{AuthorName:1})
{ "_id" : ObjectId("66162559565f33eab365f0f7"), "AuthorName" : "Thomas Friedman" }
{ "_id" : ObjectId("66162559565f33eab365f0f8"), "AuthorName" : "Ken Follett" }
{ "_id" : ObjectId("66162559565f33eab365f0f9"), "AuthorName" : "Robert Kiyosak" }
{ "_id" : ObjectId("66162559565f33eab365f0fa"), "AuthorName" : "Robin Sharma" }
{ "_id" : ObjectId("66162559565f33eab365f0fb"), "AuthorName" : "Stephen Hawking" }
{ "_id" : ObjectId("66162559565f33eab365f0fc"), "AuthorName" : "Agatha Christie" }
{ "_id" : ObjectId("66162559565f33eab365f0fd"), "AuthorName" : "Chetan Bhagat" }
{ "_id" : ObjectId("66162559565f33eab365f0fe"), "AuthorName" : "Yuval Noah
Harari" }
{ "_id" : ObjectId("66162559565f33eab365f0ff"), "AuthorName" : "J K Rollowings" }
{ "_id" : ObjectId("66162559565f33eab365f100"), "AuthorName" : "Vikram Seth" }
{ "_id" : ObjectId("66162559565f33eab365f101"), "AuthorName" : "Ravi
Subramainyan" }
>
>
> db.Author.find({},{_id:0,AuthorName:1})
{ "AuthorName" : "Thomas Friedman" }
{ "AuthorName" : "Ken Follett" }
{ "AuthorName" : "Robert Kiyosak" }
{ "AuthorName" : "Robin Sharma" }
{ "AuthorName" : "Stephen Hawking" }
{ "AuthorName" : "Agatha Christie" }
{ "AuthorName" : "Chetan Bhagat" }
{ "AuthorName" : "Yuval Noah Harari" }
{ "AuthorName" : "J K Rollowings" }
{ "AuthorName" : "Vikram Seth" }
{ "AuthorName" : "Ravi Subramainyan" }
> show collections
Author
Book
Booking
Department
Employee
Location
Member
Plan
Publisher
Rack
>
>
> db.Book.find().pretty()
{
"_id" : ObjectId("661625c4b29b1b354071963e"),
"BookId" : "B002",
"BookName" : "On Wings of Eagles",
"Catogery" : "Non-fiction",
"Cost" : 359,
"NoOfPages" : 624,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2019-12-15",
"BookLastIssuedTime" : "11:33:00",
"RackId" : "R002",
"AuthorId" : "A002"
}
{
"_id" : ObjectId("661625c4b29b1b354071963f"),
"BookId" : "B005",
"BookName" : "A Brief History of Time",
"Catogery" : "Science Fiction",
"Cost" : 185,
"NoOfPages" : 256,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-03-22",
"BookLastIssuedTime" : "09:49:00",
"RackId" : "R003",
"AuthorId" : "A005"
}
{
"_id" : ObjectId("661625c4b29b1b3540719640"),
"BookId" : "B006",
"BookName" : "Murder On The Oriental Express",
"Catogery" : "Mystery",
"Cost" : 155,
"NoOfPages" : 256,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2019-10-12",
"BookLastIssuedTime" : "14:05:00",
"RackId" : "R003",
"AuthorId" : "A006"
}
{
"_id" : ObjectId("661625c4b29b1b3540719641"),
"BookId" : "B007",
"BookName" : "Five Point Someone",
"Catogery" : "Fiction",
"Cost" : 118,
"NoOfPages" : 270,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-01-04",
"BookLastIssuedTime" : "15:01:00",
"RackId" : "R003",
"AuthorId" : "A007"
}
{
"_id" : ObjectId("661625c4b29b1b3540719642"),
"BookId" : "B008",
"BookName" : "The Incredible Banker",
"Catogery" : "Fiction",
"Cost" : 186,
"NoOfPages" : 320,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A011"
}
{
"_id" : ObjectId("661625c4b29b1b3540719643"),
"BookId" : "B001",
"BookName" : "The World Is Flat",
"Catogery" : "Non-fiction",
"Cost" : 336,
"NoOfPages" : 448,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-02-01",
"BookLastIssuedTime" : "12:23:00",
"RackId" : "R001",
"AuthorId" : "A001"
}
{
"_id" : ObjectId("661625c4b29b1b3540719644"),
"BookId" : "B009",
"BookName" : "A Brief History Of Humankind",
"Catogery" : "Fiction",
"Cost" : 125,
"NoOfPages" : 450,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A012"
}
{
"_id" : ObjectId("661625c4b29b1b3540719645"),
"BookId" : "B003",
"BookName" : "Rich Dad Poor Dad",
"Catogery" : "Self-help",
"Cost" : 359,
"NoOfPages" : 624,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2020-01-25",
"BookLastIssuedTime" : "10:11:00",
"RackId" : "R002",
"AuthorId" : "A003"
}
{
"_id" : ObjectId("661625c4b29b1b3540719646"),
"BookId" : "B004",
"BookName" : "Megaliving",
"Catogery" : "Fiction",
"Cost" : 122,
"NoOfPages" : 198,
"BookStatus" : "A",
"BookLastIssuedDate" : "2019-11-10",
"BookLastIssuedTime" : "13:27:00",
"RackId" : "R003",
"AuthorId" : "A004"
}
>
> db.Book.find({},{_id:0,Bookname:1})
{ }
{ }
{ }
{ }
{ }
{ }
{ }
{ }
{ }
> db.Book.find({},{_id:0,BookName:1})
{ "BookName" : "On Wings of Eagles" }
{ "BookName" : "A Brief History of Time" }
{ "BookName" : "Murder On The Oriental Express" }
{ "BookName" : "Five Point Someone" }
{ "BookName" : "The Incredible Banker" }
{ "BookName" : "The World Is Flat" }
{ "BookName" : "A Brief History Of Humankind" }
{ "BookName" : "Rich Dad Poor Dad" }
{ "BookName" : "Megaliving" }
>
>
>
>
> db.Book.find({},{_id:0,BookName:1,Cost:1})
{ "BookName" : "On Wings of Eagles", "Cost" : 359 }
{ "BookName" : "A Brief History of Time", "Cost" : 185 }
{ "BookName" : "Murder On The Oriental Express", "Cost" : 155 }
{ "BookName" : "Five Point Someone", "Cost" : 118 }
{ "BookName" : "The Incredible Banker", "Cost" : 186 }
{ "BookName" : "The World Is Flat", "Cost" : 336 }
{ "BookName" : "A Brief History Of Humankind", "Cost" : 125 }
{ "BookName" : "Rich Dad Poor Dad", "Cost" : 359 }
{ "BookName" : "Megaliving", "Cost" : 122 }
>
>
>
>
> db.Book.find().pretty()
{
"_id" : ObjectId("661625c4b29b1b354071963e"),
"BookId" : "B002",
"BookName" : "On Wings of Eagles",
"Catogery" : "Non-fiction",
"Cost" : 359,
"NoOfPages" : 624,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2019-12-15",
"BookLastIssuedTime" : "11:33:00",
"RackId" : "R002",
"AuthorId" : "A002"
}
{
"_id" : ObjectId("661625c4b29b1b354071963f"),
"BookId" : "B005",
"BookName" : "A Brief History of Time",
"Catogery" : "Science Fiction",
"Cost" : 185,
"NoOfPages" : 256,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-03-22",
"BookLastIssuedTime" : "09:49:00",
"RackId" : "R003",
"AuthorId" : "A005"
}
{
"_id" : ObjectId("661625c4b29b1b3540719640"),
"BookId" : "B006",
"BookName" : "Murder On The Oriental Express",
"Catogery" : "Mystery",
"Cost" : 155,
"NoOfPages" : 256,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2019-10-12",
"BookLastIssuedTime" : "14:05:00",
"RackId" : "R003",
"AuthorId" : "A006"
}
{
"_id" : ObjectId("661625c4b29b1b3540719641"),
"BookId" : "B007",
"BookName" : "Five Point Someone",
"Catogery" : "Fiction",
"Cost" : 118,
"NoOfPages" : 270,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-01-04",
"BookLastIssuedTime" : "15:01:00",
"RackId" : "R003",
"AuthorId" : "A007"
}
{
"_id" : ObjectId("661625c4b29b1b3540719642"),
"BookId" : "B008",
"BookName" : "The Incredible Banker",
"Catogery" : "Fiction",
"Cost" : 186,
"NoOfPages" : 320,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A011"
}
{
"_id" : ObjectId("661625c4b29b1b3540719643"),
"BookId" : "B001",
"BookName" : "The World Is Flat",
"Catogery" : "Non-fiction",
"Cost" : 336,
"NoOfPages" : 448,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-02-01",
"BookLastIssuedTime" : "12:23:00",
"RackId" : "R001",
"AuthorId" : "A001"
}
{
"_id" : ObjectId("661625c4b29b1b3540719644"),
"BookId" : "B009",
"BookName" : "A Brief History Of Humankind",
"Catogery" : "Fiction",
"Cost" : 125,
"NoOfPages" : 450,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A012"
}
{
"_id" : ObjectId("661625c4b29b1b3540719645"),
"BookId" : "B003",
"BookName" : "Rich Dad Poor Dad",
"Catogery" : "Self-help",
"Cost" : 359,
"NoOfPages" : 624,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2020-01-25",
"BookLastIssuedTime" : "10:11:00",
"RackId" : "R002",
"AuthorId" : "A003"
}
{
"_id" : ObjectId("661625c4b29b1b3540719646"),
"BookId" : "B004",
"BookName" : "Megaliving",
"Catogery" : "Fiction",
"Cost" : 122,
"NoOfPages" : 198,
"BookStatus" : "A",
"BookLastIssuedDate" : "2019-11-10",
"BookLastIssuedTime" : "13:27:00",
"RackId" : "R003",
"AuthorId" : "A004"
}
> db.Author.find().pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f7"),
"AuthorId" : "A001",
"AuthorName" : "Thomas Friedman",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0f9"),
"AuthorId" : "A003",
"AuthorName" : "Robert Kiyosak",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0fa"),
"AuthorId" : "A004",
"AuthorName" : "Robin Sharma",
"Gender" : "M",
"Nationality" : "Canada"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f0fe"),
"AuthorId" : "A012",
"AuthorName" : "Yuval Noah Harari",
"Gender" : "M",
"Nationality" : "Israeal"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India"
}
>
>
>
> db.Author.find({Nationality:'India'})
{ "_id" : ObjectId("66162559565f33eab365f0fd"), "AuthorId" : "A007", "AuthorName" :
"Chetan Bhagat", "Gender" : "M", "Nationality" : "India" }
{ "_id" : ObjectId("66162559565f33eab365f100"), "AuthorId" : "A008", "AuthorName" :
"Vikram Seth", "Gender" : "M", "Nationality" : "India" }
{ "_id" : ObjectId("66162559565f33eab365f101"), "AuthorId" : "A011", "AuthorName" :
"Ravi Subramainyan", "Gender" : "M", "Nationality" : "India" }
>
>
> db.Author.find({Nationality:'India'}).pretty()
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India"
}
>
>
>
> db.Author.find({Nationality:'UK'}).pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK"
}
> show collections
Author
Book
Booking
Department
Employee
Location
Member
Plan
Publisher
Rack
> db.Book.find()
{ "_id" : ObjectId("661625c4b29b1b354071963e"), "BookId" : "B002", "BookName" : "On
Wings of Eagles", "Catogery" : "Non-fiction", "Cost" : 359, "NoOfPages" : 624,
"BookStatus" : "NA", "BookLastIssuedDate" : "2019-12-15", "BookLastIssuedTime" :
"11:33:00", "RackId" : "R002", "AuthorId" : "A002" }
{ "_id" : ObjectId("661625c4b29b1b354071963f"), "BookId" : "B005", "BookName" : "A
Brief History of Time", "Catogery" : "Science Fiction", "Cost" : 185, "NoOfPages" :
256, "BookStatus" : "A", "BookLastIssuedDate" : "2020-03-22",
"BookLastIssuedTime" : "09:49:00", "RackId" : "R003", "AuthorId" : "A005" }
{ "_id" : ObjectId("661625c4b29b1b3540719640"), "BookId" : "B006", "BookName" :
"Murder On The Oriental Express", "Catogery" : "Mystery", "Cost" : 155, "NoOfPages"
: 256, "BookStatus" : "NA", "BookLastIssuedDate" : "2019-10-12",
"BookLastIssuedTime" : "14:05:00", "RackId" : "R003", "AuthorId" : "A006" }
{ "_id" : ObjectId("661625c4b29b1b3540719641"), "BookId" : "B007", "BookName" :
"Five Point Someone", "Catogery" : "Fiction", "Cost" : 118, "NoOfPages" : 270,
"BookStatus" : "A", "BookLastIssuedDate" : "2020-01-04", "BookLastIssuedTime" :
"15:01:00", "RackId" : "R003", "AuthorId" : "A007" }
{ "_id" : ObjectId("661625c4b29b1b3540719642"), "BookId" : "B008", "BookName" :
"The Incredible Banker", "Catogery" : "Fiction", "Cost" : 186, "NoOfPages" : 320,
"BookStatus" : "A", "BookLastIssuedDate" : "2020-05-07", "BookLastIssuedTime" :
"11:01:00", "RackId" : "R002", "AuthorId" : "A011" }
{ "_id" : ObjectId("661625c4b29b1b3540719643"), "BookId" : "B001", "BookName" :
"The World Is Flat", "Catogery" : "Non-fiction", "Cost" : 336, "NoOfPages" : 448,
"BookStatus" : "A", "BookLastIssuedDate" : "2020-02-01", "BookLastIssuedTime" :
"12:23:00", "RackId" : "R001", "AuthorId" : "A001" }
{ "_id" : ObjectId("661625c4b29b1b3540719644"), "BookId" : "B009", "BookName" : "A
Brief History Of Humankind", "Catogery" : "Fiction", "Cost" : 125, "NoOfPages" :
450, "BookStatus" : "A", "BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00", "RackId" : "R002", "AuthorId" : "A012" }
{ "_id" : ObjectId("661625c4b29b1b3540719645"), "BookId" : "B003", "BookName" :
"Rich Dad Poor Dad", "Catogery" : "Self-help", "Cost" : 359, "NoOfPages" : 624,
"BookStatus" : "NA", "BookLastIssuedDate" : "2020-01-25", "BookLastIssuedTime" :
"10:11:00", "RackId" : "R002", "AuthorId" : "A003" }
{ "_id" : ObjectId("661625c4b29b1b3540719646"), "BookId" : "B004", "BookName" :
"Megaliving", "Catogery" : "Fiction", "Cost" : 122, "NoOfPages" : 198, "BookStatus"
: "A", "BookLastIssuedDate" : "2019-11-10", "BookLastIssuedTime" : "13:27:00",
"RackId" : "R003", "AuthorId" : "A004" }
>
>
>
> db.Book.find({Catogery:'Fiction'})
{ "_id" : ObjectId("661625c4b29b1b3540719641"), "BookId" : "B007", "BookName" :
"Five Point Someone", "Catogery" : "Fiction", "Cost" : 118, "NoOfPages" : 270,
"BookStatus" : "A", "BookLastIssuedDate" : "2020-01-04", "BookLastIssuedTime" :
"15:01:00", "RackId" : "R003", "AuthorId" : "A007" }
{ "_id" : ObjectId("661625c4b29b1b3540719642"), "BookId" : "B008", "BookName" :
"The Incredible Banker", "Catogery" : "Fiction", "Cost" : 186, "NoOfPages" : 320,
"BookStatus" : "A", "BookLastIssuedDate" : "2020-05-07", "BookLastIssuedTime" :
"11:01:00", "RackId" : "R002", "AuthorId" : "A011" }
{ "_id" : ObjectId("661625c4b29b1b3540719644"), "BookId" : "B009", "BookName" : "A
Brief History Of Humankind", "Catogery" : "Fiction", "Cost" : 125, "NoOfPages" :
450, "BookStatus" : "A", "BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00", "RackId" : "R002", "AuthorId" : "A012" }
{ "_id" : ObjectId("661625c4b29b1b3540719646"), "BookId" : "B004", "BookName" :
"Megaliving", "Catogery" : "Fiction", "Cost" : 122, "NoOfPages" : 198, "BookStatus"
: "A", "BookLastIssuedDate" : "2019-11-10", "BookLastIssuedTime" : "13:27:00",
"RackId" : "R003", "AuthorId" : "A004" }
> db.Book.find({Catogery:'Fiction'}).pretty()
{
"_id" : ObjectId("661625c4b29b1b3540719641"),
"BookId" : "B007",
"BookName" : "Five Point Someone",
"Catogery" : "Fiction",
"Cost" : 118,
"NoOfPages" : 270,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-01-04",
"BookLastIssuedTime" : "15:01:00",
"RackId" : "R003",
"AuthorId" : "A007"
}
{
"_id" : ObjectId("661625c4b29b1b3540719642"),
"BookId" : "B008",
"BookName" : "The Incredible Banker",
"Catogery" : "Fiction",
"Cost" : 186,
"NoOfPages" : 320,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A011"
}
{
"_id" : ObjectId("661625c4b29b1b3540719644"),
"BookId" : "B009",
"BookName" : "A Brief History Of Humankind",
"Catogery" : "Fiction",
"Cost" : 125,
"NoOfPages" : 450,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A012"
}
{
"_id" : ObjectId("661625c4b29b1b3540719646"),
"BookId" : "B004",
"BookName" : "Megaliving",
"Catogery" : "Fiction",
"Cost" : 122,
"NoOfPages" : 198,
"BookStatus" : "A",
"BookLastIssuedDate" : "2019-11-10",
"BookLastIssuedTime" : "13:27:00",
"RackId" : "R003",
"AuthorId" : "A004"
}
>
>
>
> db.Book.find({Bookname:1,Catogery:1},{Catogery:'Fiction'}).pretty()
>
>
> db.Book.find({BookName:1,Catogery:1},{Catogery:'Fiction'}).pretty()
>
>
>
> db.Book.find({BookName:1,Catogery:1},{Catogery:'Fiction'}).pretty()
>
>
>
> db.Book.find({Catogery:'Fiction'},{BookName:1,Catogery:1})
{ "_id" : ObjectId("661625c4b29b1b3540719641"), "BookName" : "Five Point Someone",
"Catogery" : "Fiction" }
{ "_id" : ObjectId("661625c4b29b1b3540719642"), "BookName" : "The Incredible
Banker", "Catogery" : "Fiction" }
{ "_id" : ObjectId("661625c4b29b1b3540719644"), "BookName" : "A Brief History Of
Humankind", "Catogery" : "Fiction" }
{ "_id" : ObjectId("661625c4b29b1b3540719646"), "BookName" : "Megaliving",
"Catogery" : "Fiction" }
>
>
>
> db.Book.find({Catogery:'Fiction'},{BookName:1,Catogery:1}).pretty()
{
"_id" : ObjectId("661625c4b29b1b3540719641"),
"BookName" : "Five Point Someone",
"Catogery" : "Fiction"
}
{
"_id" : ObjectId("661625c4b29b1b3540719642"),
"BookName" : "The Incredible Banker",
"Catogery" : "Fiction"
}
{
"_id" : ObjectId("661625c4b29b1b3540719644"),
"BookName" : "A Brief History Of Humankind",
"Catogery" : "Fiction"
}
{
"_id" : ObjectId("661625c4b29b1b3540719646"),
"BookName" : "Megaliving",
"Catogery" : "Fiction"
}
>
> db.Book.find({Catogery:'Fiction'},{_id:0,BookName:1,Catogery:1}).pretty()
{ "BookName" : "Five Point Someone", "Catogery" : "Fiction" }
{ "BookName" : "The Incredible Banker", "Catogery" : "Fiction" }
{ "BookName" : "A Brief History Of Humankind", "Catogery" : "Fiction" }
{ "BookName" : "Megaliving", "Catogery" : "Fiction" }
>
>
>
>
> show collections
Author
Book
Booking
Department
Employee
Location
Member
Plan
Publisher
Rack
> db.Employee.find().pretty()
{
"_id" : ObjectId("661625c6a9cff9360a49d1ab"),
"EmployeeId" : "E001",
"eFName" : "Amit",
"eLName" : "Sharma",
"Sex" : "M",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ac"),
"EmployeeId" : "E002",
"eFName" : "Janki",
"eLName" : "Srivastava",
"Sex" : "F",
"DOJ" : "9/1/2015",
"Designation" : "Librarian",
"DeptId" : "D001",
"LocationId" : "L001"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ad"),
"EmployeeId" : "E004",
"eFName" : "Romila",
"eLName" : "Arora",
"Sex" : "L",
"DOJ" : "1/1/2014",
"Designation" : "Director",
"DeptId" : "D004",
"LocationId" : "L001"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ae"),
"EmployeeId" : "E006",
"eFName" : "Chandrakant",
"eLName" : "Bakshi",
"Sex" : "M",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1af"),
"EmployeeId" : "E003",
"eFName" : "Kishan",
"eLName" : "Rane",
"Sex" : "M",
"DOJ" : "10/1/2017",
"Designation" : "Sweeper",
"DeptId" : "D003",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1b0"),
"EmployeeId" : "E007",
"eFName" : "Kajal",
"eLName" : "Oza",
"Sex" : "F",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1b1"),
"EmployeeId" : "E008",
"eFName" : "Devaki",
"eLName" : "Pandit",
"Sex" : "F",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
>
>
> db.Employee.find({Designation:'Accountant'})
{ "_id" : ObjectId("661625c6a9cff9360a49d1ab"), "EmployeeId" : "E001", "eFName" :
"Amit", "eLName" : "Sharma", "Sex" : "M", "DOJ" : "3/25/2018", "Designation" :
"Accountant", "DeptId" : "D002", "LocationId" : "L003" }
{ "_id" : ObjectId("661625c6a9cff9360a49d1ae"), "EmployeeId" : "E006", "eFName" :
"Chandrakant", "eLName" : "Bakshi", "Sex" : "M", "DOJ" : "3/25/2018", "Designation"
: "Accountant", "DeptId" : "D002", "LocationId" : "L003" }
{ "_id" : ObjectId("661625c6a9cff9360a49d1b0"), "EmployeeId" : "E007", "eFName" :
"Kajal", "eLName" : "Oza", "Sex" : "F", "DOJ" : "3/25/2018", "Designation" :
"Accountant", "DeptId" : "D002", "LocationId" : "L003" }
{ "_id" : ObjectId("661625c6a9cff9360a49d1b1"), "EmployeeId" : "E008", "eFName" :
"Devaki", "eLName" : "Pandit", "Sex" : "F", "DOJ" : "3/25/2018", "Designation" :
"Accountant", "DeptId" : "D002", "LocationId" : "L003" }
>
>
>
> db.Employee.find({Designation:'Accountant'}).pretty()
{
"_id" : ObjectId("661625c6a9cff9360a49d1ab"),
"EmployeeId" : "E001",
"eFName" : "Amit",
"eLName" : "Sharma",
"Sex" : "M",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ae"),
"EmployeeId" : "E006",
"eFName" : "Chandrakant",
"eLName" : "Bakshi",
"Sex" : "M",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1b0"),
"EmployeeId" : "E007",
"eFName" : "Kajal",
"eLName" : "Oza",
"Sex" : "F",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1b1"),
"EmployeeId" : "E008",
"eFName" : "Devaki",
"eLName" : "Pandit",
"Sex" : "F",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
> db.Employee.find({Designation:'Accountant'},
{_id:0,eFName:1,Designation:1}).pretty()
{ "eFName" : "Amit", "Designation" : "Accountant" }
{ "eFName" : "Chandrakant", "Designation" : "Accountant" }
{ "eFName" : "Kajal", "Designation" : "Accountant" }
{ "eFName" : "Devaki", "Designation" : "Accountant" }
>
>
>
> db.Author.find().pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f7"),
"AuthorId" : "A001",
"AuthorName" : "Thomas Friedman",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0f9"),
"AuthorId" : "A003",
"AuthorName" : "Robert Kiyosak",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0fa"),
"AuthorId" : "A004",
"AuthorName" : "Robin Sharma",
"Gender" : "M",
"Nationality" : "Canada"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f0fe"),
"AuthorId" : "A012",
"AuthorName" : "Yuval Noah Harari",
"Gender" : "M",
"Nationality" : "Israeal"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India"
}
> db.Author.find({Nationality:'UK'}).pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK"
}
>
>
>
> db.Author.find({Nationality:'UK',Gender:'M'}).pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK"
}
> show collections
Author
Book
Booking
Department
Employee
Location
Member
Plan
Publisher
Rack
>
>
> db.Employee.find().pretty()
{
"_id" : ObjectId("661625c6a9cff9360a49d1ab"),
"EmployeeId" : "E001",
"eFName" : "Amit",
"eLName" : "Sharma",
"Sex" : "M",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ac"),
"EmployeeId" : "E002",
"eFName" : "Janki",
"eLName" : "Srivastava",
"Sex" : "F",
"DOJ" : "9/1/2015",
"Designation" : "Librarian",
"DeptId" : "D001",
"LocationId" : "L001"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ad"),
"EmployeeId" : "E004",
"eFName" : "Romila",
"eLName" : "Arora",
"Sex" : "L",
"DOJ" : "1/1/2014",
"Designation" : "Director",
"DeptId" : "D004",
"LocationId" : "L001"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ae"),
"EmployeeId" : "E006",
"eFName" : "Chandrakant",
"eLName" : "Bakshi",
"Sex" : "M",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1af"),
"EmployeeId" : "E003",
"eFName" : "Kishan",
"eLName" : "Rane",
"Sex" : "M",
"DOJ" : "10/1/2017",
"Designation" : "Sweeper",
"DeptId" : "D003",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1b0"),
"EmployeeId" : "E007",
"eFName" : "Kajal",
"eLName" : "Oza",
"Sex" : "F",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1b1"),
"EmployeeId" : "E008",
"eFName" : "Devaki",
"eLName" : "Pandit",
"Sex" : "F",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
> db.Employee.find({Designation:'Accountant'}).pretty()
{
"_id" : ObjectId("661625c6a9cff9360a49d1ab"),
"EmployeeId" : "E001",
"eFName" : "Amit",
"eLName" : "Sharma",
"Sex" : "M",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ae"),
"EmployeeId" : "E006",
"eFName" : "Chandrakant",
"eLName" : "Bakshi",
"Sex" : "M",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1b0"),
"EmployeeId" : "E007",
"eFName" : "Kajal",
"eLName" : "Oza",
"Sex" : "F",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1b1"),
"EmployeeId" : "E008",
"eFName" : "Devaki",
"eLName" : "Pandit",
"Sex" : "F",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
> db.Employee.find({Designation:'Accountant',Sex:'F'}).pretty()
{
"_id" : ObjectId("661625c6a9cff9360a49d1b0"),
"EmployeeId" : "E007",
"eFName" : "Kajal",
"eLName" : "Oza",
"Sex" : "F",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1b1"),
"EmployeeId" : "E008",
"eFName" : "Devaki",
"eLName" : "Pandit",
"Sex" : "F",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
> db.Employee.find({Designation:'Accountant',Sex:'F'},{_id:0,eFName:1,Sex:1,
Designation:1}).pretty()
{ "eFName" : "Kajal", "Sex" : "F", "Designation" : "Accountant" }
{ "eFName" : "Devaki", "Sex" : "F", "Designation" : "Accountant" }
>
>
>
> db.Author.find().pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f7"),
"AuthorId" : "A001",
"AuthorName" : "Thomas Friedman",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0f9"),
"AuthorId" : "A003",
"AuthorName" : "Robert Kiyosak",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0fa"),
"AuthorId" : "A004",
"AuthorName" : "Robin Sharma",
"Gender" : "M",
"Nationality" : "Canada"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f0fe"),
"AuthorId" : "A012",
"AuthorName" : "Yuval Noah Harari",
"Gender" : "M",
"Nationality" : "Israeal"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India"
}
>
>
>
> db.Author.find({$or:[{Nationality:'India'},{Nationality:'Canada'}]})
{ "_id" : ObjectId("66162559565f33eab365f0fa"), "AuthorId" : "A004", "AuthorName" :
"Robin Sharma", "Gender" : "M", "Nationality" : "Canada" }
{ "_id" : ObjectId("66162559565f33eab365f0fd"), "AuthorId" : "A007", "AuthorName" :
"Chetan Bhagat", "Gender" : "M", "Nationality" : "India" }
{ "_id" : ObjectId("66162559565f33eab365f100"), "AuthorId" : "A008", "AuthorName" :
"Vikram Seth", "Gender" : "M", "Nationality" : "India" }
{ "_id" : ObjectId("66162559565f33eab365f101"), "AuthorId" : "A011", "AuthorName" :
"Ravi Subramainyan", "Gender" : "M", "Nationality" : "India" }
>
>
>
> db.Author.find({$or:[{Nationality:'India'},{Nationality:'Canada'}]}).pretty()
{
"_id" : ObjectId("66162559565f33eab365f0fa"),
"AuthorId" : "A004",
"AuthorName" : "Robin Sharma",
"Gender" : "M",
"Nationality" : "Canada"
}
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India"
}
>
>
>
>
> db.Employee.find({$or:[{Designation:'Accountant'},{'Librarian'}]})
2024-04-10T11:52:37.468+0530 E QUERY [js] uncaught exception: SyntaxError:
missing : after property id :
@(shell):1:62
>
>
>
> db.Employee.find({$or:[{Designation:'Accountant'},{Designation:'Librarian'}]})
{ "_id" : ObjectId("661625c6a9cff9360a49d1ab"), "EmployeeId" : "E001", "eFName" :
"Amit", "eLName" : "Sharma", "Sex" : "M", "DOJ" : "3/25/2018", "Designation" :
"Accountant", "DeptId" : "D002", "LocationId" : "L003" }
{ "_id" : ObjectId("661625c6a9cff9360a49d1ac"), "EmployeeId" : "E002", "eFName" :
"Janki", "eLName" : "Srivastava", "Sex" : "F", "DOJ" : "9/1/2015", "Designation" :
"Librarian", "DeptId" : "D001", "LocationId" : "L001" }
{ "_id" : ObjectId("661625c6a9cff9360a49d1ae"), "EmployeeId" : "E006", "eFName" :
"Chandrakant", "eLName" : "Bakshi", "Sex" : "M", "DOJ" : "3/25/2018", "Designation"
: "Accountant", "DeptId" : "D002", "LocationId" : "L003" }
{ "_id" : ObjectId("661625c6a9cff9360a49d1b0"), "EmployeeId" : "E007", "eFName" :
"Kajal", "eLName" : "Oza", "Sex" : "F", "DOJ" : "3/25/2018", "Designation" :
"Accountant", "DeptId" : "D002", "LocationId" : "L003" }
{ "_id" : ObjectId("661625c6a9cff9360a49d1b1"), "EmployeeId" : "E008", "eFName" :
"Devaki", "eLName" : "Pandit", "Sex" : "F", "DOJ" : "3/25/2018", "Designation" :
"Accountant", "DeptId" : "D002", "LocationId" : "L003" }
>
>
>
> db.Employee.find({$or:[{Designation:'Accountant'},{Designation:'Librarian'}]},
{_id:0,Designation:1})
{ "Designation" : "Accountant" }
{ "Designation" : "Librarian" }
{ "Designation" : "Accountant" }
{ "Designation" : "Accountant" }
{ "Designation" : "Accountant" }
> db.Employee.find({$or:[{Designation:'Accountant'},{Designation:'Librarian'}]},
{_id:0,Designation:1,eFName:1})
{ "eFName" : "Amit", "Designation" : "Accountant" }
{ "eFName" : "Janki", "Designation" : "Librarian" }
{ "eFName" : "Chandrakant", "Designation" : "Accountant" }
{ "eFName" : "Kajal", "Designation" : "Accountant" }
{ "eFName" : "Devaki", "Designation" : "Accountant" }
>
>
>
>
> db.Employee.find({$or:[{Designation:'Accountant'},{Designation:'Librarian'},
{Designation:'Sweeper'}]},{_id:0,Designation:1,eFName:1})
{ "eFName" : "Amit", "Designation" : "Accountant" }
{ "eFName" : "Janki", "Designation" : "Librarian" }
{ "eFName" : "Chandrakant", "Designation" : "Accountant" }
{ "eFName" : "Kishan", "Designation" : "Sweeper" }
{ "eFName" : "Kajal", "Designation" : "Accountant" }
{ "eFName" : "Devaki", "Designation" : "Accountant" }
>
>
> db.Employee.find({Designation:{$in:['Accountant','Librarian','Sweeper']}},
{Designation:'Sweeper'}]},{_id:0,Designation:1,eFName:1})
2024-04-10T11:59:58.812+0530 E QUERY [js] uncaught exception: SyntaxError:
missing ) after argument list :
@(shell):1:97
>
>
>
> db.Employee.find({Designation:{$in:['Accountant','Librarian','Sweeper']})
... ^C

> db.Employee.find({Designation:{$in:['Accountant','Librarian','Sweeper']}}
... ^C

> db.Employee.find({Designation:{$in:['Accountant','Librarian','Sweeper']}})
{ "_id" : ObjectId("661625c6a9cff9360a49d1ab"), "EmployeeId" : "E001", "eFName" :
"Amit", "eLName" : "Sharma", "Sex" : "M", "DOJ" : "3/25/2018", "Designation" :
"Accountant", "DeptId" : "D002", "LocationId" : "L003" }
{ "_id" : ObjectId("661625c6a9cff9360a49d1ac"), "EmployeeId" : "E002", "eFName" :
"Janki", "eLName" : "Srivastava", "Sex" : "F", "DOJ" : "9/1/2015", "Designation" :
"Librarian", "DeptId" : "D001", "LocationId" : "L001" }
{ "_id" : ObjectId("661625c6a9cff9360a49d1ae"), "EmployeeId" : "E006", "eFName" :
"Chandrakant", "eLName" : "Bakshi", "Sex" : "M", "DOJ" : "3/25/2018", "Designation"
: "Accountant", "DeptId" : "D002", "LocationId" : "L003" }
{ "_id" : ObjectId("661625c6a9cff9360a49d1af"), "EmployeeId" : "E003", "eFName" :
"Kishan", "eLName" : "Rane", "Sex" : "M", "DOJ" : "10/1/2017", "Designation" :
"Sweeper", "DeptId" : "D003", "LocationId" : "L003" }
{ "_id" : ObjectId("661625c6a9cff9360a49d1b0"), "EmployeeId" : "E007", "eFName" :
"Kajal", "eLName" : "Oza", "Sex" : "F", "DOJ" : "3/25/2018", "Designation" :
"Accountant", "DeptId" : "D002", "LocationId" : "L003" }
{ "_id" : ObjectId("661625c6a9cff9360a49d1b1"), "EmployeeId" : "E008", "eFName" :
"Devaki", "eLName" : "Pandit", "Sex" : "F", "DOJ" : "3/25/2018", "Designation" :
"Accountant", "DeptId" : "D002", "LocationId" : "L003" }
> db.Employee.find({Designation:{$in:
['Accountant','Librarian','Sweeper']}}).pretty()
{
"_id" : ObjectId("661625c6a9cff9360a49d1ab"),
"EmployeeId" : "E001",
"eFName" : "Amit",
"eLName" : "Sharma",
"Sex" : "M",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ac"),
"EmployeeId" : "E002",
"eFName" : "Janki",
"eLName" : "Srivastava",
"Sex" : "F",
"DOJ" : "9/1/2015",
"Designation" : "Librarian",
"DeptId" : "D001",
"LocationId" : "L001"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ae"),
"EmployeeId" : "E006",
"eFName" : "Chandrakant",
"eLName" : "Bakshi",
"Sex" : "M",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1af"),
"EmployeeId" : "E003",
"eFName" : "Kishan",
"eLName" : "Rane",
"Sex" : "M",
"DOJ" : "10/1/2017",
"Designation" : "Sweeper",
"DeptId" : "D003",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1b0"),
"EmployeeId" : "E007",
"eFName" : "Kajal",
"eLName" : "Oza",
"Sex" : "F",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1b1"),
"EmployeeId" : "E008",
"eFName" : "Devaki",
"eLName" : "Pandit",
"Sex" : "F",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
>
>
>
> db.Employee.find({Designation:{$in:['Accountant','Librarian','Sweeper']}},
{_id:0,eFName:1,Designation:1}).pretty()
{ "eFName" : "Amit", "Designation" : "Accountant" }
{ "eFName" : "Janki", "Designation" : "Librarian" }
{ "eFName" : "Chandrakant", "Designation" : "Accountant" }
{ "eFName" : "Kishan", "Designation" : "Sweeper" }
{ "eFName" : "Kajal", "Designation" : "Accountant" }
{ "eFName" : "Devaki", "Designation" : "Accountant" }
> db.Book.find({_id:0,BookName:1,Cost:1}).pretty()
>
>
>
> db.Book.find().pretty()
{
"_id" : ObjectId("661625c4b29b1b354071963e"),
"BookId" : "B002",
"BookName" : "On Wings of Eagles",
"Catogery" : "Non-fiction",
"Cost" : 359,
"NoOfPages" : 624,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2019-12-15",
"BookLastIssuedTime" : "11:33:00",
"RackId" : "R002",
"AuthorId" : "A002"
}
{
"_id" : ObjectId("661625c4b29b1b354071963f"),
"BookId" : "B005",
"BookName" : "A Brief History of Time",
"Catogery" : "Science Fiction",
"Cost" : 185,
"NoOfPages" : 256,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-03-22",
"BookLastIssuedTime" : "09:49:00",
"RackId" : "R003",
"AuthorId" : "A005"
}
{
"_id" : ObjectId("661625c4b29b1b3540719640"),
"BookId" : "B006",
"BookName" : "Murder On The Oriental Express",
"Catogery" : "Mystery",
"Cost" : 155,
"NoOfPages" : 256,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2019-10-12",
"BookLastIssuedTime" : "14:05:00",
"RackId" : "R003",
"AuthorId" : "A006"
}
{
"_id" : ObjectId("661625c4b29b1b3540719641"),
"BookId" : "B007",
"BookName" : "Five Point Someone",
"Catogery" : "Fiction",
"Cost" : 118,
"NoOfPages" : 270,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-01-04",
"BookLastIssuedTime" : "15:01:00",
"RackId" : "R003",
"AuthorId" : "A007"
}
{
"_id" : ObjectId("661625c4b29b1b3540719642"),
"BookId" : "B008",
"BookName" : "The Incredible Banker",
"Catogery" : "Fiction",
"Cost" : 186,
"NoOfPages" : 320,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A011"
}
{
"_id" : ObjectId("661625c4b29b1b3540719643"),
"BookId" : "B001",
"BookName" : "The World Is Flat",
"Catogery" : "Non-fiction",
"Cost" : 336,
"NoOfPages" : 448,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-02-01",
"BookLastIssuedTime" : "12:23:00",
"RackId" : "R001",
"AuthorId" : "A001"
}
{
"_id" : ObjectId("661625c4b29b1b3540719644"),
"BookId" : "B009",
"BookName" : "A Brief History Of Humankind",
"Catogery" : "Fiction",
"Cost" : 125,
"NoOfPages" : 450,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A012"
}
{
"_id" : ObjectId("661625c4b29b1b3540719645"),
"BookId" : "B003",
"BookName" : "Rich Dad Poor Dad",
"Catogery" : "Self-help",
"Cost" : 359,
"NoOfPages" : 624,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2020-01-25",
"BookLastIssuedTime" : "10:11:00",
"RackId" : "R002",
"AuthorId" : "A003"
}
{
"_id" : ObjectId("661625c4b29b1b3540719646"),
"BookId" : "B004",
"BookName" : "Megaliving",
"Catogery" : "Fiction",
"Cost" : 122,
"NoOfPages" : 198,
"BookStatus" : "A",
"BookLastIssuedDate" : "2019-11-10",
"BookLastIssuedTime" : "13:27:00",
"RackId" : "R003",
"AuthorId" : "A004"
}
> db.Book.find({},{_id:0,BookName:1,Cost:1}).pretty()
{ "BookName" : "On Wings of Eagles", "Cost" : 359 }
{ "BookName" : "A Brief History of Time", "Cost" : 185 }
{ "BookName" : "Murder On The Oriental Express", "Cost" : 155 }
{ "BookName" : "Five Point Someone", "Cost" : 118 }
{ "BookName" : "The Incredible Banker", "Cost" : 186 }
{ "BookName" : "The World Is Flat", "Cost" : 336 }
{ "BookName" : "A Brief History Of Humankind", "Cost" : 125 }
{ "BookName" : "Rich Dad Poor Dad", "Cost" : 359 }
{ "BookName" : "Megaliving", "Cost" : 122 }
>
>
>
>
>
> db.Book.find({Cost:{$lt:200}},{_id:0,BookName:1,Cost:1}).pretty()
{ "BookName" : "A Brief History of Time", "Cost" : 185 }
{ "BookName" : "Murder On The Oriental Express", "Cost" : 155 }
{ "BookName" : "Five Point Someone", "Cost" : 118 }
{ "BookName" : "The Incredible Banker", "Cost" : 186 }
{ "BookName" : "A Brief History Of Humankind", "Cost" : 125 }
{ "BookName" : "Megaliving", "Cost" : 122 }
>
>
> db.Book.find({Cost:{$lt:185}},{_id:0,BookName:1,Cost:1}).pretty()
{ "BookName" : "Murder On The Oriental Express", "Cost" : 155 }
{ "BookName" : "Five Point Someone", "Cost" : 118 }
{ "BookName" : "A Brief History Of Humankind", "Cost" : 125 }
{ "BookName" : "Megaliving", "Cost" : 122 }
>
>
> db.Book.find({Cost:{$lte:185}},{_id:0,BookName:1,Cost:1}).pretty()
{ "BookName" : "A Brief History of Time", "Cost" : 185 }
{ "BookName" : "Murder On The Oriental Express", "Cost" : 155 }
{ "BookName" : "Five Point Someone", "Cost" : 118 }
{ "BookName" : "A Brief History Of Humankind", "Cost" : 125 }
{ "BookName" : "Megaliving", "Cost" : 122 }
>
>
>
>
> db.Book.find({Cost:{$gt:200}},{_id:0,BookName:1,Cost:1}).pretty()
{ "BookName" : "On Wings of Eagles", "Cost" : 359 }
{ "BookName" : "The World Is Flat", "Cost" : 336 }
{ "BookName" : "Rich Dad Poor Dad", "Cost" : 359 }
>
>
> db.Book.find({Cost:{$ne:359}},{_id:0,BookName:1,Cost:1}).pretty()
{ "BookName" : "A Brief History of Time", "Cost" : 185 }
{ "BookName" : "Murder On The Oriental Express", "Cost" : 155 }
{ "BookName" : "Five Point Someone", "Cost" : 118 }
{ "BookName" : "The Incredible Banker", "Cost" : 186 }
{ "BookName" : "The World Is Flat", "Cost" : 336 }
{ "BookName" : "A Brief History Of Humankind", "Cost" : 125 }
{ "BookName" : "Megaliving", "Cost" : 122 }
>
>
>
>
> db.Book.find({_id:0,BookName:1,Cost:1}).pretty()
>
>
>
> db.Book.find({},{_id:0,BookName:1,Cost:1}).pretty()
{ "BookName" : "On Wings of Eagles", "Cost" : 359 }
{ "BookName" : "A Brief History of Time", "Cost" : 185 }
{ "BookName" : "Murder On The Oriental Express", "Cost" : 155 }
{ "BookName" : "Five Point Someone", "Cost" : 118 }
{ "BookName" : "The Incredible Banker", "Cost" : 186 }
{ "BookName" : "The World Is Flat", "Cost" : 336 }
{ "BookName" : "A Brief History Of Humankind", "Cost" : 125 }
{ "BookName" : "Rich Dad Poor Dad", "Cost" : 359 }
{ "BookName" : "Megaliving", "Cost" : 122 }
>
>
>
>
>
> db.Book.find({},{_id:0,BookName:1,NoOfPages:1}).pretty()
{ "BookName" : "On Wings of Eagles", "NoOfPages" : 624 }
{ "BookName" : "A Brief History of Time", "NoOfPages" : 256 }
{ "BookName" : "Murder On The Oriental Express", "NoOfPages" : 256 }
{ "BookName" : "Five Point Someone", "NoOfPages" : 270 }
{ "BookName" : "The Incredible Banker", "NoOfPages" : 320 }
{ "BookName" : "The World Is Flat", "NoOfPages" : 448 }
{ "BookName" : "A Brief History Of Humankind", "NoOfPages" : 450 }
{ "BookName" : "Rich Dad Poor Dad", "NoOfPages" : 624 }
{ "BookName" : "Megaliving", "NoOfPages" : 198 }
>
>
>
> db.Book.find({},{_id:0,BookName:1,NoOfPages:1}).sort({NoOfPages:1})
{ "BookName" : "Megaliving", "NoOfPages" : 198 }
{ "BookName" : "A Brief History of Time", "NoOfPages" : 256 }
{ "BookName" : "Murder On The Oriental Express", "NoOfPages" : 256 }
{ "BookName" : "Five Point Someone", "NoOfPages" : 270 }
{ "BookName" : "The Incredible Banker", "NoOfPages" : 320 }
{ "BookName" : "The World Is Flat", "NoOfPages" : 448 }
{ "BookName" : "A Brief History Of Humankind", "NoOfPages" : 450 }
{ "BookName" : "On Wings of Eagles", "NoOfPages" : 624 }
{ "BookName" : "Rich Dad Poor Dad", "NoOfPages" : 624 }
>
>
> db.Book.find({},{_id:0,BookName:1,NoOfPages:1}).sort({NoOfPages:-1})
{ "BookName" : "On Wings of Eagles", "NoOfPages" : 624 }
{ "BookName" : "Rich Dad Poor Dad", "NoOfPages" : 624 }
{ "BookName" : "A Brief History Of Humankind", "NoOfPages" : 450 }
{ "BookName" : "The World Is Flat", "NoOfPages" : 448 }
{ "BookName" : "The Incredible Banker", "NoOfPages" : 320 }
{ "BookName" : "Five Point Someone", "NoOfPages" : 270 }
{ "BookName" : "A Brief History of Time", "NoOfPages" : 256 }
{ "BookName" : "Murder On The Oriental Express", "NoOfPages" : 256 }
{ "BookName" : "Megaliving", "NoOfPages" : 198 }
>
>
>
>
> db.Book.find({},{_id:0,BookName:1,NoOfPages:1}).sort({BookName:1})
{ "BookName" : "A Brief History Of Humankind", "NoOfPages" : 450 }
{ "BookName" : "A Brief History of Time", "NoOfPages" : 256 }
{ "BookName" : "Five Point Someone", "NoOfPages" : 270 }
{ "BookName" : "Megaliving", "NoOfPages" : 198 }
{ "BookName" : "Murder On The Oriental Express", "NoOfPages" : 256 }
{ "BookName" : "On Wings of Eagles", "NoOfPages" : 624 }
{ "BookName" : "Rich Dad Poor Dad", "NoOfPages" : 624 }
{ "BookName" : "The Incredible Banker", "NoOfPages" : 320 }
{ "BookName" : "The World Is Flat", "NoOfPages" : 448 }
>
>
>
>
> db.Book.find({},{_id:0,BookName:1,NoOfPages:1}).sort({BookName:-1})
{ "BookName" : "The World Is Flat", "NoOfPages" : 448 }
{ "BookName" : "The Incredible Banker", "NoOfPages" : 320 }
{ "BookName" : "Rich Dad Poor Dad", "NoOfPages" : 624 }
{ "BookName" : "On Wings of Eagles", "NoOfPages" : 624 }
{ "BookName" : "Murder On The Oriental Express", "NoOfPages" : 256 }
{ "BookName" : "Megaliving", "NoOfPages" : 198 }
{ "BookName" : "Five Point Someone", "NoOfPages" : 270 }
{ "BookName" : "A Brief History of Time", "NoOfPages" : 256 }
{ "BookName" : "A Brief History Of Humankind", "NoOfPages" : 450 }
>
>
>
> db.Employee.aggregate([{$group:{_id:'$DeptId',Empcount:{$sum:1}}}])
{ "_id" : "D002", "Empcount" : 4 }
{ "_id" : "D003", "Empcount" : 1 }
{ "_id" : "D004", "Empcount" : 1 }
{ "_id" : "D001", "Empcount" : 1 }
>
>
>
> db.Employee.find({},{_id:0,DeptId:1})
{ "DeptId" : "D002" }
{ "DeptId" : "D001" }
{ "DeptId" : "D004" }
{ "DeptId" : "D002" }
{ "DeptId" : "D003" }
{ "DeptId" : "D002" }
{ "DeptId" : "D002" }
>
>
>
>
> db.Employee.aggregate([{$group:{_id:'$Designation',DesgCnt:{$sum:1}}}])
{ "_id" : "Librarian", "DesgCnt" : 1 }
{ "_id" : "Sweeper", "DesgCnt" : 1 }
{ "_id" : "Director", "DesgCnt" : 1 }
{ "_id" : "Accountant", "DesgCnt" : 4 }
>
>
> db.Book.find({},{_id:0,BookName:1,NoOfPages:1}).pretty()
{ "BookName" : "On Wings of Eagles", "NoOfPages" : 624 }
{ "BookName" : "A Brief History of Time", "NoOfPages" : 256 }
{ "BookName" : "Murder On The Oriental Express", "NoOfPages" : 256 }
{ "BookName" : "Five Point Someone", "NoOfPages" : 270 }
{ "BookName" : "The Incredible Banker", "NoOfPages" : 320 }
{ "BookName" : "The World Is Flat", "NoOfPages" : 448 }
{ "BookName" : "A Brief History Of Humankind", "NoOfPages" : 450 }
{ "BookName" : "Rich Dad Poor Dad", "NoOfPages" : 624 }
{ "BookName" : "Megaliving", "NoOfPages" : 198 }
>
>
>
>
> db.Book.find({},{_id:0,BookName:1,Cost:1}).pretty()
{ "BookName" : "On Wings of Eagles", "Cost" : 359 }
{ "BookName" : "A Brief History of Time", "Cost" : 185 }
{ "BookName" : "Murder On The Oriental Express", "Cost" : 155 }
{ "BookName" : "Five Point Someone", "Cost" : 118 }
{ "BookName" : "The Incredible Banker", "Cost" : 186 }
{ "BookName" : "The World Is Flat", "Cost" : 336 }
{ "BookName" : "A Brief History Of Humankind", "Cost" : 125 }
{ "BookName" : "Rich Dad Poor Dad", "Cost" : 359 }
{ "BookName" : "Megaliving", "Cost" : 122 }
>
>
>
> db.Book.find({},{_id:0,Catogery:1,Cost:1}).pretty()
{ "Catogery" : "Non-fiction", "Cost" : 359 }
{ "Catogery" : "Science Fiction", "Cost" : 185 }
{ "Catogery" : "Mystery", "Cost" : 155 }
{ "Catogery" : "Fiction", "Cost" : 118 }
{ "Catogery" : "Fiction", "Cost" : 186 }
{ "Catogery" : "Non-fiction", "Cost" : 336 }
{ "Catogery" : "Fiction", "Cost" : 125 }
{ "Catogery" : "Self-help", "Cost" : 359 }
{ "Catogery" : "Fiction", "Cost" : 122 }
>
>
>
> db.Book.aggregate([{$group:{_id:'$Catogery',PerCatogeryTotalCost:
{$sum:'$cost'}}}])
{ "_id" : "Self-help", "PerCatogeryTotalCost" : 0 }
{ "_id" : "Science Fiction", "PerCatogeryTotalCost" : 0 }
{ "_id" : "Non-fiction", "PerCatogeryTotalCost" : 0 }
{ "_id" : "Mystery", "PerCatogeryTotalCost" : 0 }
{ "_id" : "Fiction", "PerCatogeryTotalCost" : 0 }
> db.Book.aggregate([{$group:{_id:'$Catogery',PerCatogeryTotalCost:
{$sum:'$Cost'}}}])
{ "_id" : "Fiction", "PerCatogeryTotalCost" : 551 }
{ "_id" : "Non-fiction", "PerCatogeryTotalCost" : 695 }
{ "_id" : "Mystery", "PerCatogeryTotalCost" : 155 }
{ "_id" : "Self-help", "PerCatogeryTotalCost" : 359 }
{ "_id" : "Science Fiction", "PerCatogeryTotalCost" : 185 }
>
>
>
>
>
>
> db.Book.aggregate([{$group:{_id:'$Catogery',PerCatogeryTotalCost:
{$sum:'$Cost'}}}])
{ "_id" : "Self-help", "PerCatogeryTotalCost" : 359 }
{ "_id" : "Science Fiction", "PerCatogeryTotalCost" : 185 }
{ "_id" : "Non-fiction", "PerCatogeryTotalCost" : 695 }
{ "_id" : "Mystery", "PerCatogeryTotalCost" : 155 }
{ "_id" : "Fiction", "PerCatogeryTotalCost" : 551 }
>
>
>
>
> db.Book.aggregate([{$group:{_id:'$Catogery',PerCatogeryTotalCost:
{$avg:'$Cost'}}}])
{ "_id" : "Self-help", "PerCatogeryTotalCost" : 359 }
{ "_id" : "Science Fiction", "PerCatogeryTotalCost" : 185 }
{ "_id" : "Non-fiction", "PerCatogeryTotalCost" : 347.5 }
{ "_id" : "Mystery", "PerCatogeryTotalCost" : 155 }
{ "_id" : "Fiction", "PerCatogeryTotalCost" : 137.75 }
>
>
> db.Book.aggregate([{$group:{_id:'$Catogery',PerCatogeryTotalCost:
{$max:'$Cost'}}}])
{ "_id" : "Self-help", "PerCatogeryTotalCost" : 359 }
{ "_id" : "Science Fiction", "PerCatogeryTotalCost" : 185 }
{ "_id" : "Non-fiction", "PerCatogeryTotalCost" : 359 }
{ "_id" : "Mystery", "PerCatogeryTotalCost" : 155 }
{ "_id" : "Fiction", "PerCatogeryTotalCost" : 186 }
>
>
>
>
> db.Book.aggregate([{$group:{_id:'$Catogery',PerCatogeryTotalCost:
{$min:'$Cost'}}}])
{ "_id" : "Fiction", "PerCatogeryTotalCost" : 118 }
{ "_id" : "Mystery", "PerCatogeryTotalCost" : 155 }
{ "_id" : "Non-fiction", "PerCatogeryTotalCost" : 336 }
{ "_id" : "Science Fiction", "PerCatogeryTotalCost" : 185 }
{ "_id" : "Self-help", "PerCatogeryTotalCost" : 359 }
>
>
>
> db.Author.find().pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f7"),
"AuthorId" : "A001",
"AuthorName" : "Thomas Friedman",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0f9"),
"AuthorId" : "A003",
"AuthorName" : "Robert Kiyosak",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0fa"),
"AuthorId" : "A004",
"AuthorName" : "Robin Sharma",
"Gender" : "M",
"Nationality" : "Canada"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f0fe"),
"AuthorId" : "A012",
"AuthorName" : "Yuval Noah Harari",
"Gender" : "M",
"Nationality" : "Israeal"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India"
}
>
>
>
> db.Author.update({},{$set:{Ccd:'IN'}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
>
>
>
> db.Author.find().pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f7"),
"AuthorId" : "A001",
"AuthorName" : "Thomas Friedman",
"Gender" : "M",
"Nationality" : "USA",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0f9"),
"AuthorId" : "A003",
"AuthorName" : "Robert Kiyosak",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0fa"),
"AuthorId" : "A004",
"AuthorName" : "Robin Sharma",
"Gender" : "M",
"Nationality" : "Canada"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f0fe"),
"AuthorId" : "A012",
"AuthorName" : "Yuval Noah Harari",
"Gender" : "M",
"Nationality" : "Israeal"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India"
}
> db.Author.updateMany({},{$set:{Ccd:'IN'}})
{ "acknowledged" : true, "matchedCount" : 11, "modifiedCount" : 10 }
>
>
> db.Author.find().pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f7"),
"AuthorId" : "A001",
"AuthorName" : "Thomas Friedman",
"Gender" : "M",
"Nationality" : "USA",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0f9"),
"AuthorId" : "A003",
"AuthorName" : "Robert Kiyosak",
"Gender" : "M",
"Nationality" : "USA",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0fa"),
"AuthorId" : "A004",
"AuthorName" : "Robin Sharma",
"Gender" : "M",
"Nationality" : "Canada",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0fe"),
"AuthorId" : "A012",
"AuthorName" : "Yuval Noah Harari",
"Gender" : "M",
"Nationality" : "Israeal",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India",
"Ccd" : "IN"
}
>
>
>
> db.Author.updateMany({Nationality:'USA'},{$set:{Ccd:'US'}})
{ "acknowledged" : true, "matchedCount" : 2, "modifiedCount" : 2 }
>
>
>
> db.Author.find().pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f7"),
"AuthorId" : "A001",
"AuthorName" : "Thomas Friedman",
"Gender" : "M",
"Nationality" : "USA",
"Ccd" : "US"
}
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0f9"),
"AuthorId" : "A003",
"AuthorName" : "Robert Kiyosak",
"Gender" : "M",
"Nationality" : "USA",
"Ccd" : "US"
}
{
"_id" : ObjectId("66162559565f33eab365f0fa"),
"AuthorId" : "A004",
"AuthorName" : "Robin Sharma",
"Gender" : "M",
"Nationality" : "Canada",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0fe"),
"AuthorId" : "A012",
"AuthorName" : "Yuval Noah Harari",
"Gender" : "M",
"Nationality" : "Israeal",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India",
"Ccd" : "IN"
}
> db.Author.updateMany({Nationality:'UK'},{$set:{currency:'GBP'}})
{ "acknowledged" : true, "matchedCount" : 4, "modifiedCount" : 4 }
>
>
>
>
> db.Author.find().pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f7"),
"AuthorId" : "A001",
"AuthorName" : "Thomas Friedman",
"Gender" : "M",
"Nationality" : "USA",
"Ccd" : "US"
}
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK",
"Ccd" : "IN",
"currency" : "GBP"
}
{
"_id" : ObjectId("66162559565f33eab365f0f9"),
"AuthorId" : "A003",
"AuthorName" : "Robert Kiyosak",
"Gender" : "M",
"Nationality" : "USA",
"Ccd" : "US"
}
{
"_id" : ObjectId("66162559565f33eab365f0fa"),
"AuthorId" : "A004",
"AuthorName" : "Robin Sharma",
"Gender" : "M",
"Nationality" : "Canada",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK",
"Ccd" : "IN",
"currency" : "GBP"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK",
"Ccd" : "IN",
"currency" : "GBP"
}
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0fe"),
"AuthorId" : "A012",
"AuthorName" : "Yuval Noah Harari",
"Gender" : "M",
"Nationality" : "Israeal",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK",
"Ccd" : "IN",
"currency" : "GBP"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India",
"Ccd" : "IN"
}
> db.Author.update({"Nationality" : "India"},{$unset:{Ccd:''}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
>
>
>
>
> db.Author.updateMany({"Nationality" : "India"},{$unset:{Ccd:''}})
{ "acknowledged" : true, "matchedCount" : 3, "modifiedCount" : 2 }
>
>
>
> db.Author.find().pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f7"),
"AuthorId" : "A001",
"AuthorName" : "Thomas Friedman",
"Gender" : "M",
"Nationality" : "USA",
"Ccd" : "US"
}
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK",
"Ccd" : "IN",
"currency" : "GBP"
}
{
"_id" : ObjectId("66162559565f33eab365f0f9"),
"AuthorId" : "A003",
"AuthorName" : "Robert Kiyosak",
"Gender" : "M",
"Nationality" : "USA",
"Ccd" : "US"
}
{
"_id" : ObjectId("66162559565f33eab365f0fa"),
"AuthorId" : "A004",
"AuthorName" : "Robin Sharma",
"Gender" : "M",
"Nationality" : "Canada",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK",
"Ccd" : "IN",
"currency" : "GBP"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK",
"Ccd" : "IN",
"currency" : "GBP"
}
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f0fe"),
"AuthorId" : "A012",
"AuthorName" : "Yuval Noah Harari",
"Gender" : "M",
"Nationality" : "Israeal",
"Ccd" : "IN"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK",
"Ccd" : "IN",
"currency" : "GBP"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India"
}
>
>
>
>
> db.Author.updateMany({},{$unset:{Ccd:''}})
{ "acknowledged" : true, "matchedCount" : 11, "modifiedCount" : 8 }
>
>
>
> db.Author.find().pretty()
{
"_id" : ObjectId("66162559565f33eab365f0f7"),
"AuthorId" : "A001",
"AuthorName" : "Thomas Friedman",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0f8"),
"AuthorId" : "A002",
"AuthorName" : "Ken Follett",
"Gender" : "M",
"Nationality" : "UK",
"currency" : "GBP"
}
{
"_id" : ObjectId("66162559565f33eab365f0f9"),
"AuthorId" : "A003",
"AuthorName" : "Robert Kiyosak",
"Gender" : "M",
"Nationality" : "USA"
}
{
"_id" : ObjectId("66162559565f33eab365f0fa"),
"AuthorId" : "A004",
"AuthorName" : "Robin Sharma",
"Gender" : "M",
"Nationality" : "Canada"
}
{
"_id" : ObjectId("66162559565f33eab365f0fb"),
"AuthorId" : "A005",
"AuthorName" : "Stephen Hawking",
"Gender" : "M",
"Nationality" : "UK",
"currency" : "GBP"
}
{
"_id" : ObjectId("66162559565f33eab365f0fc"),
"AuthorId" : "A006",
"AuthorName" : "Agatha Christie",
"Gender" : "F",
"Nationality" : "UK",
"currency" : "GBP"
}
{
"_id" : ObjectId("66162559565f33eab365f0fd"),
"AuthorId" : "A007",
"AuthorName" : "Chetan Bhagat",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f0fe"),
"AuthorId" : "A012",
"AuthorName" : "Yuval Noah Harari",
"Gender" : "M",
"Nationality" : "Israeal"
}
{
"_id" : ObjectId("66162559565f33eab365f0ff"),
"AuthorId" : "A009",
"AuthorName" : "J K Rollowings",
"Gender" : "F",
"Nationality" : "UK",
"currency" : "GBP"
}
{
"_id" : ObjectId("66162559565f33eab365f100"),
"AuthorId" : "A008",
"AuthorName" : "Vikram Seth",
"Gender" : "M",
"Nationality" : "India"
}
{
"_id" : ObjectId("66162559565f33eab365f101"),
"AuthorId" : "A011",
"AuthorName" : "Ravi Subramainyan",
"Gender" : "M",
"Nationality" : "India"
}
>
>
>
>
> show collections
Author
Book
Booking
Department
Employee
Location
Member
Plan
Publisher
Rack
>
> db.Location.find()
{ "_id" : ObjectId("661625c7ba933648748a2abc"), "LocationId" : "L002", "City" :
"Pune", "State" : "MH", "PinCode" : 411005 }
{ "_id" : ObjectId("661625c7ba933648748a2abd"), "LocationId" : "L003", "City" :
"Bangalore", "State" : "KA", "PinCode" : 560001 }
{ "_id" : ObjectId("661625c7ba933648748a2abe"), "LocationId" : "L004", "City" :
"Ahemadabad", "State" : "GJ", "PinCode" : 380001 }
{ "_id" : ObjectId("661625c7ba933648748a2abf"), "LocationId" : "L001", "City" :
"Mumbai", "State" : "MH", "PinCode" : 400001 }
{ "_id" : ObjectId("661625c7ba933648748a2ac0"), "LocationId" : "L005", "City" :
"Delhi", "State" : "DL", "PinCode" : 110001 }
>
>
> db.Location.find().pretty()
{
"_id" : ObjectId("661625c7ba933648748a2abc"),
"LocationId" : "L002",
"City" : "Pune",
"State" : "MH",
"PinCode" : 411005
}
{
"_id" : ObjectId("661625c7ba933648748a2abd"),
"LocationId" : "L003",
"City" : "Bangalore",
"State" : "KA",
"PinCode" : 560001
}
{
"_id" : ObjectId("661625c7ba933648748a2abe"),
"LocationId" : "L004",
"City" : "Ahemadabad",
"State" : "GJ",
"PinCode" : 380001
}
{
"_id" : ObjectId("661625c7ba933648748a2abf"),
"LocationId" : "L001",
"City" : "Mumbai",
"State" : "MH",
"PinCode" : 400001
}
{
"_id" : ObjectId("661625c7ba933648748a2ac0"),
"LocationId" : "L005",
"City" : "Delhi",
"State" : "DL",
"PinCode" : 110001
}
> db.Location.deleteOne({LocationId:'L005'})
{ "acknowledged" : true, "deletedCount" : 1 }
>
>
> db.Location.find().pretty()
{
"_id" : ObjectId("661625c7ba933648748a2abc"),
"LocationId" : "L002",
"City" : "Pune",
"State" : "MH",
"PinCode" : 411005
}
{
"_id" : ObjectId("661625c7ba933648748a2abd"),
"LocationId" : "L003",
"City" : "Bangalore",
"State" : "KA",
"PinCode" : 560001
}
{
"_id" : ObjectId("661625c7ba933648748a2abe"),
"LocationId" : "L004",
"City" : "Ahemadabad",
"State" : "GJ",
"PinCode" : 380001
}
{
"_id" : ObjectId("661625c7ba933648748a2abf"),
"LocationId" : "L001",
"City" : "Mumbai",
"State" : "MH",
"PinCode" : 400001
}
>
>
>
>
> db.Employee.find().pretty()
{
"_id" : ObjectId("661625c6a9cff9360a49d1ab"),
"EmployeeId" : "E001",
"eFName" : "Amit",
"eLName" : "Sharma",
"Sex" : "M",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ac"),
"EmployeeId" : "E002",
"eFName" : "Janki",
"eLName" : "Srivastava",
"Sex" : "F",
"DOJ" : "9/1/2015",
"Designation" : "Librarian",
"DeptId" : "D001",
"LocationId" : "L001"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ad"),
"EmployeeId" : "E004",
"eFName" : "Romila",
"eLName" : "Arora",
"Sex" : "L",
"DOJ" : "1/1/2014",
"Designation" : "Director",
"DeptId" : "D004",
"LocationId" : "L001"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ae"),
"EmployeeId" : "E006",
"eFName" : "Chandrakant",
"eLName" : "Bakshi",
"Sex" : "M",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1af"),
"EmployeeId" : "E003",
"eFName" : "Kishan",
"eLName" : "Rane",
"Sex" : "M",
"DOJ" : "10/1/2017",
"Designation" : "Sweeper",
"DeptId" : "D003",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1b0"),
"EmployeeId" : "E007",
"eFName" : "Kajal",
"eLName" : "Oza",
"Sex" : "F",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1b1"),
"EmployeeId" : "E008",
"eFName" : "Devaki",
"eLName" : "Pandit",
"Sex" : "F",
"DOJ" : "3/25/2018",
"Designation" : "Accountant",
"DeptId" : "D002",
"LocationId" : "L003"
}
>
>
>
>
> db.Employee.delete({Designation:'Accountant'})
2024-04-10T13:11:32.103+0530 E QUERY [js] uncaught exception: TypeError:
db.Employee.delete is not a function :
@(shell):1:1
>
>
>
> db.Employee.deleteMany({Designation:'Accountant'})
{ "acknowledged" : true, "deletedCount" : 4 }
>
>
>
> db.Employee.find().pretty()
{
"_id" : ObjectId("661625c6a9cff9360a49d1ac"),
"EmployeeId" : "E002",
"eFName" : "Janki",
"eLName" : "Srivastava",
"Sex" : "F",
"DOJ" : "9/1/2015",
"Designation" : "Librarian",
"DeptId" : "D001",
"LocationId" : "L001"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ad"),
"EmployeeId" : "E004",
"eFName" : "Romila",
"eLName" : "Arora",
"Sex" : "L",
"DOJ" : "1/1/2014",
"Designation" : "Director",
"DeptId" : "D004",
"LocationId" : "L001"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1af"),
"EmployeeId" : "E003",
"eFName" : "Kishan",
"eLName" : "Rane",
"Sex" : "M",
"DOJ" : "10/1/2017",
"Designation" : "Sweeper",
"DeptId" : "D003",
"LocationId" : "L003"
}
> db.Employee.update({"EmployeeId" : "E004"},{$set:{Sex:'F'}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
>
>
>
>
> db.Employee.find().pretty()
{
"_id" : ObjectId("661625c6a9cff9360a49d1ac"),
"EmployeeId" : "E002",
"eFName" : "Janki",
"eLName" : "Srivastava",
"Sex" : "F",
"DOJ" : "9/1/2015",
"Designation" : "Librarian",
"DeptId" : "D001",
"LocationId" : "L001"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1ad"),
"EmployeeId" : "E004",
"eFName" : "Romila",
"eLName" : "Arora",
"Sex" : "F",
"DOJ" : "1/1/2014",
"Designation" : "Director",
"DeptId" : "D004",
"LocationId" : "L001"
}
{
"_id" : ObjectId("661625c6a9cff9360a49d1af"),
"EmployeeId" : "E003",
"eFName" : "Kishan",
"eLName" : "Rane",
"Sex" : "M",
"DOJ" : "10/1/2017",
"Designation" : "Sweeper",
"DeptId" : "D003",
"LocationId" : "L003"
}
>
>
>
> db.Employee.remove({"Sex" : "F"})
WriteResult({ "nRemoved" : 2 })
>
>
>
> db.Employee.find().pretty()
{
"_id" : ObjectId("661625c6a9cff9360a49d1af"),
"EmployeeId" : "E003",
"eFName" : "Kishan",
"eLName" : "Rane",
"Sex" : "M",
"DOJ" : "10/1/2017",
"Designation" : "Sweeper",
"DeptId" : "D003",
"LocationId" : "L003"
}
> db.Book.find().pretty()
{
"_id" : ObjectId("661625c4b29b1b354071963e"),
"BookId" : "B002",
"BookName" : "On Wings of Eagles",
"Catogery" : "Non-fiction",
"Cost" : 359,
"NoOfPages" : 624,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2019-12-15",
"BookLastIssuedTime" : "11:33:00",
"RackId" : "R002",
"AuthorId" : "A002"
}
{
"_id" : ObjectId("661625c4b29b1b354071963f"),
"BookId" : "B005",
"BookName" : "A Brief History of Time",
"Catogery" : "Science Fiction",
"Cost" : 185,
"NoOfPages" : 256,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-03-22",
"BookLastIssuedTime" : "09:49:00",
"RackId" : "R003",
"AuthorId" : "A005"
}
{
"_id" : ObjectId("661625c4b29b1b3540719640"),
"BookId" : "B006",
"BookName" : "Murder On The Oriental Express",
"Catogery" : "Mystery",
"Cost" : 155,
"NoOfPages" : 256,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2019-10-12",
"BookLastIssuedTime" : "14:05:00",
"RackId" : "R003",
"AuthorId" : "A006"
}
{
"_id" : ObjectId("661625c4b29b1b3540719641"),
"BookId" : "B007",
"BookName" : "Five Point Someone",
"Catogery" : "Fiction",
"Cost" : 118,
"NoOfPages" : 270,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-01-04",
"BookLastIssuedTime" : "15:01:00",
"RackId" : "R003",
"AuthorId" : "A007"
}
{
"_id" : ObjectId("661625c4b29b1b3540719642"),
"BookId" : "B008",
"BookName" : "The Incredible Banker",
"Catogery" : "Fiction",
"Cost" : 186,
"NoOfPages" : 320,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A011"
}
{
"_id" : ObjectId("661625c4b29b1b3540719643"),
"BookId" : "B001",
"BookName" : "The World Is Flat",
"Catogery" : "Non-fiction",
"Cost" : 336,
"NoOfPages" : 448,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-02-01",
"BookLastIssuedTime" : "12:23:00",
"RackId" : "R001",
"AuthorId" : "A001"
}
{
"_id" : ObjectId("661625c4b29b1b3540719644"),
"BookId" : "B009",
"BookName" : "A Brief History Of Humankind",
"Catogery" : "Fiction",
"Cost" : 125,
"NoOfPages" : 450,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A012"
}
{
"_id" : ObjectId("661625c4b29b1b3540719645"),
"BookId" : "B003",
"BookName" : "Rich Dad Poor Dad",
"Catogery" : "Self-help",
"Cost" : 359,
"NoOfPages" : 624,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2020-01-25",
"BookLastIssuedTime" : "10:11:00",
"RackId" : "R002",
"AuthorId" : "A003"
}
{
"_id" : ObjectId("661625c4b29b1b3540719646"),
"BookId" : "B004",
"BookName" : "Megaliving",
"Catogery" : "Fiction",
"Cost" : 122,
"NoOfPages" : 198,
"BookStatus" : "A",
"BookLastIssuedDate" : "2019-11-10",
"BookLastIssuedTime" : "13:27:00",
"RackId" : "R003",
"AuthorId" : "A004"
}
> db.Book.distinct('Catogery')
[ "Fiction", "Mystery", "Non-fiction", "Science Fiction", "Self-help" ]
>
>
>
>
> db.Book.distinct('Catogery').count()
2024-04-10T13:17:14.920+0530 E QUERY [js] uncaught exception: TypeError:
db.Book.distinct(...).count is not a function :
@(shell):1:1
>
>
>
> db.Book.find().count()
9
>
>
> db.Book.find({Catogery:'Fiction'}).count()
4
>
>
>
> db.Book.find().pretty()
{
"_id" : ObjectId("661625c4b29b1b354071963e"),
"BookId" : "B002",
"BookName" : "On Wings of Eagles",
"Catogery" : "Non-fiction",
"Cost" : 359,
"NoOfPages" : 624,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2019-12-15",
"BookLastIssuedTime" : "11:33:00",
"RackId" : "R002",
"AuthorId" : "A002"
}
{
"_id" : ObjectId("661625c4b29b1b354071963f"),
"BookId" : "B005",
"BookName" : "A Brief History of Time",
"Catogery" : "Science Fiction",
"Cost" : 185,
"NoOfPages" : 256,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-03-22",
"BookLastIssuedTime" : "09:49:00",
"RackId" : "R003",
"AuthorId" : "A005"
}
{
"_id" : ObjectId("661625c4b29b1b3540719640"),
"BookId" : "B006",
"BookName" : "Murder On The Oriental Express",
"Catogery" : "Mystery",
"Cost" : 155,
"NoOfPages" : 256,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2019-10-12",
"BookLastIssuedTime" : "14:05:00",
"RackId" : "R003",
"AuthorId" : "A006"
}
{
"_id" : ObjectId("661625c4b29b1b3540719641"),
"BookId" : "B007",
"BookName" : "Five Point Someone",
"Catogery" : "Fiction",
"Cost" : 118,
"NoOfPages" : 270,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-01-04",
"BookLastIssuedTime" : "15:01:00",
"RackId" : "R003",
"AuthorId" : "A007"
}
{
"_id" : ObjectId("661625c4b29b1b3540719642"),
"BookId" : "B008",
"BookName" : "The Incredible Banker",
"Catogery" : "Fiction",
"Cost" : 186,
"NoOfPages" : 320,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A011"
}
{
"_id" : ObjectId("661625c4b29b1b3540719643"),
"BookId" : "B001",
"BookName" : "The World Is Flat",
"Catogery" : "Non-fiction",
"Cost" : 336,
"NoOfPages" : 448,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-02-01",
"BookLastIssuedTime" : "12:23:00",
"RackId" : "R001",
"AuthorId" : "A001"
}
{
"_id" : ObjectId("661625c4b29b1b3540719644"),
"BookId" : "B009",
"BookName" : "A Brief History Of Humankind",
"Catogery" : "Fiction",
"Cost" : 125,
"NoOfPages" : 450,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A012"
}
{
"_id" : ObjectId("661625c4b29b1b3540719645"),
"BookId" : "B003",
"BookName" : "Rich Dad Poor Dad",
"Catogery" : "Self-help",
"Cost" : 359,
"NoOfPages" : 624,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2020-01-25",
"BookLastIssuedTime" : "10:11:00",
"RackId" : "R002",
"AuthorId" : "A003"
}
{
"_id" : ObjectId("661625c4b29b1b3540719646"),
"BookId" : "B004",
"BookName" : "Megaliving",
"Catogery" : "Fiction",
"Cost" : 122,
"NoOfPages" : 198,
"BookStatus" : "A",
"BookLastIssuedDate" : "2019-11-10",
"BookLastIssuedTime" : "13:27:00",
"RackId" : "R003",
"AuthorId" : "A004"
}
> db.Book.createIndex({BookId:1}).pretty()
2024-04-10T13:19:52.968+0530 E QUERY [js] uncaught exception: TypeError:
db.Book.createIndex(...).pretty is not a function :
@(shell):1:1
>
>
>
>
> db.Book.ensureIndex({BookId:1}).pretty()
2024-04-10T13:20:23.987+0530 E QUERY [js] uncaught exception: TypeError:
db.Book.ensureIndex(...).pretty is not a function :
@(shell):1:1
>
>
>
> db.Book.createIndex({BookId:1})
{
"numIndexesBefore" : 2,
"numIndexesAfter" : 2,
"note" : "all indexes already exist",
"ok" : 1
}
>
>
> db.Book.createIndex({BookName:1})
{
"numIndexesBefore" : 2,
"numIndexesAfter" : 3,
"createdCollectionAutomatically" : false,
"ok" : 1
}
> db.Book.find()
{ "_id" : ObjectId("661625c4b29b1b354071963e"), "BookId" : "B002", "BookName" : "On
Wings of Eagles", "Catogery" : "Non-fiction", "Cost" : 359, "NoOfPages" : 624,
"BookStatus" : "NA", "BookLastIssuedDate" : "2019-12-15", "BookLastIssuedTime" :
"11:33:00", "RackId" : "R002", "AuthorId" : "A002" }
{ "_id" : ObjectId("661625c4b29b1b354071963f"), "BookId" : "B005", "BookName" : "A
Brief History of Time", "Catogery" : "Science Fiction", "Cost" : 185, "NoOfPages" :
256, "BookStatus" : "A", "BookLastIssuedDate" : "2020-03-22",
"BookLastIssuedTime" : "09:49:00", "RackId" : "R003", "AuthorId" : "A005" }
{ "_id" : ObjectId("661625c4b29b1b3540719640"), "BookId" : "B006", "BookName" :
"Murder On The Oriental Express", "Catogery" : "Mystery", "Cost" : 155, "NoOfPages"
: 256, "BookStatus" : "NA", "BookLastIssuedDate" : "2019-10-12",
"BookLastIssuedTime" : "14:05:00", "RackId" : "R003", "AuthorId" : "A006" }
{ "_id" : ObjectId("661625c4b29b1b3540719641"), "BookId" : "B007", "BookName" :
"Five Point Someone", "Catogery" : "Fiction", "Cost" : 118, "NoOfPages" : 270,
"BookStatus" : "A", "BookLastIssuedDate" : "2020-01-04", "BookLastIssuedTime" :
"15:01:00", "RackId" : "R003", "AuthorId" : "A007" }
{ "_id" : ObjectId("661625c4b29b1b3540719642"), "BookId" : "B008", "BookName" :
"The Incredible Banker", "Catogery" : "Fiction", "Cost" : 186, "NoOfPages" : 320,
"BookStatus" : "A", "BookLastIssuedDate" : "2020-05-07", "BookLastIssuedTime" :
"11:01:00", "RackId" : "R002", "AuthorId" : "A011" }
{ "_id" : ObjectId("661625c4b29b1b3540719643"), "BookId" : "B001", "BookName" :
"The World Is Flat", "Catogery" : "Non-fiction", "Cost" : 336, "NoOfPages" : 448,
"BookStatus" : "A", "BookLastIssuedDate" : "2020-02-01", "BookLastIssuedTime" :
"12:23:00", "RackId" : "R001", "AuthorId" : "A001" }
{ "_id" : ObjectId("661625c4b29b1b3540719644"), "BookId" : "B009", "BookName" : "A
Brief History Of Humankind", "Catogery" : "Fiction", "Cost" : 125, "NoOfPages" :
450, "BookStatus" : "A", "BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00", "RackId" : "R002", "AuthorId" : "A012" }
{ "_id" : ObjectId("661625c4b29b1b3540719645"), "BookId" : "B003", "BookName" :
"Rich Dad Poor Dad", "Catogery" : "Self-help", "Cost" : 359, "NoOfPages" : 624,
"BookStatus" : "NA", "BookLastIssuedDate" : "2020-01-25", "BookLastIssuedTime" :
"10:11:00", "RackId" : "R002", "AuthorId" : "A003" }
{ "_id" : ObjectId("661625c4b29b1b3540719646"), "BookId" : "B004", "BookName" :
"Megaliving", "Catogery" : "Fiction", "Cost" : 122, "NoOfPages" : 198, "BookStatus"
: "A", "BookLastIssuedDate" : "2019-11-10", "BookLastIssuedTime" : "13:27:00",
"RackId" : "R003", "AuthorId" : "A004" }
>
>
>
> db.Book.find().pretty()
{
"_id" : ObjectId("661625c4b29b1b354071963e"),
"BookId" : "B002",
"BookName" : "On Wings of Eagles",
"Catogery" : "Non-fiction",
"Cost" : 359,
"NoOfPages" : 624,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2019-12-15",
"BookLastIssuedTime" : "11:33:00",
"RackId" : "R002",
"AuthorId" : "A002"
}
{
"_id" : ObjectId("661625c4b29b1b354071963f"),
"BookId" : "B005",
"BookName" : "A Brief History of Time",
"Catogery" : "Science Fiction",
"Cost" : 185,
"NoOfPages" : 256,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-03-22",
"BookLastIssuedTime" : "09:49:00",
"RackId" : "R003",
"AuthorId" : "A005"
}
{
"_id" : ObjectId("661625c4b29b1b3540719640"),
"BookId" : "B006",
"BookName" : "Murder On The Oriental Express",
"Catogery" : "Mystery",
"Cost" : 155,
"NoOfPages" : 256,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2019-10-12",
"BookLastIssuedTime" : "14:05:00",
"RackId" : "R003",
"AuthorId" : "A006"
}
{
"_id" : ObjectId("661625c4b29b1b3540719641"),
"BookId" : "B007",
"BookName" : "Five Point Someone",
"Catogery" : "Fiction",
"Cost" : 118,
"NoOfPages" : 270,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-01-04",
"BookLastIssuedTime" : "15:01:00",
"RackId" : "R003",
"AuthorId" : "A007"
}
{
"_id" : ObjectId("661625c4b29b1b3540719642"),
"BookId" : "B008",
"BookName" : "The Incredible Banker",
"Catogery" : "Fiction",
"Cost" : 186,
"NoOfPages" : 320,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A011"
}
{
"_id" : ObjectId("661625c4b29b1b3540719643"),
"BookId" : "B001",
"BookName" : "The World Is Flat",
"Catogery" : "Non-fiction",
"Cost" : 336,
"NoOfPages" : 448,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-02-01",
"BookLastIssuedTime" : "12:23:00",
"RackId" : "R001",
"AuthorId" : "A001"
}
{
"_id" : ObjectId("661625c4b29b1b3540719644"),
"BookId" : "B009",
"BookName" : "A Brief History Of Humankind",
"Catogery" : "Fiction",
"Cost" : 125,
"NoOfPages" : 450,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A012"
}
{
"_id" : ObjectId("661625c4b29b1b3540719645"),
"BookId" : "B003",
"BookName" : "Rich Dad Poor Dad",
"Catogery" : "Self-help",
"Cost" : 359,
"NoOfPages" : 624,
"BookStatus" : "NA",
"BookLastIssuedDate" : "2020-01-25",
"BookLastIssuedTime" : "10:11:00",
"RackId" : "R002",
"AuthorId" : "A003"
}
{
"_id" : ObjectId("661625c4b29b1b3540719646"),
"BookId" : "B004",
"BookName" : "Megaliving",
"Catogery" : "Fiction",
"Cost" : 122,
"NoOfPages" : 198,
"BookStatus" : "A",
"BookLastIssuedDate" : "2019-11-10",
"BookLastIssuedTime" : "13:27:00",
"RackId" : "R003",
"AuthorId" : "A004"
}
> db.Book.find({$or:[{Catogery:'Fiction},{BookStatus:'A'}]}).pretty()
2024-04-10T13:25:00.844+0530 E QUERY [js] uncaught exception: SyntaxError:
missing } after property list :
@(shell):1:52
>
>
>
> db.Book.find({$or:[{Catogery:'Fiction'},{BookStatus:'A'}]}).pretty()
{
"_id" : ObjectId("661625c4b29b1b354071963f"),
"BookId" : "B005",
"BookName" : "A Brief History of Time",
"Catogery" : "Science Fiction",
"Cost" : 185,
"NoOfPages" : 256,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-03-22",
"BookLastIssuedTime" : "09:49:00",
"RackId" : "R003",
"AuthorId" : "A005"
}
{
"_id" : ObjectId("661625c4b29b1b3540719641"),
"BookId" : "B007",
"BookName" : "Five Point Someone",
"Catogery" : "Fiction",
"Cost" : 118,
"NoOfPages" : 270,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-01-04",
"BookLastIssuedTime" : "15:01:00",
"RackId" : "R003",
"AuthorId" : "A007"
}
{
"_id" : ObjectId("661625c4b29b1b3540719642"),
"BookId" : "B008",
"BookName" : "The Incredible Banker",
"Catogery" : "Fiction",
"Cost" : 186,
"NoOfPages" : 320,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A011"
}
{
"_id" : ObjectId("661625c4b29b1b3540719643"),
"BookId" : "B001",
"BookName" : "The World Is Flat",
"Catogery" : "Non-fiction",
"Cost" : 336,
"NoOfPages" : 448,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-02-01",
"BookLastIssuedTime" : "12:23:00",
"RackId" : "R001",
"AuthorId" : "A001"
}
{
"_id" : ObjectId("661625c4b29b1b3540719644"),
"BookId" : "B009",
"BookName" : "A Brief History Of Humankind",
"Catogery" : "Fiction",
"Cost" : 125,
"NoOfPages" : 450,
"BookStatus" : "A",
"BookLastIssuedDate" : "2020-05-07",
"BookLastIssuedTime" : "11:01:00",
"RackId" : "R002",
"AuthorId" : "A012"
}
{
"_id" : ObjectId("661625c4b29b1b3540719646"),
"BookId" : "B004",
"BookName" : "Megaliving",
"Catogery" : "Fiction",
"Cost" : 122,
"NoOfPages" : 198,
"BookStatus" : "A",
"BookLastIssuedDate" : "2019-11-10",
"BookLastIssuedTime" : "13:27:00",
"RackId" : "R003",
"AuthorId" : "A004"
}
>
>
>
> db.Book.find({$or:[{Catogery:'Fiction'},{BookStatus:'A'}]},
{Catogery:1,BookStatus:1})
{ "_id" : ObjectId("661625c4b29b1b354071963f"), "Catogery" : "Science Fiction",
"BookStatus" : "A" }
{ "_id" : ObjectId("661625c4b29b1b3540719641"), "Catogery" : "Fiction",
"BookStatus" : "A" }
{ "_id" : ObjectId("661625c4b29b1b3540719642"), "Catogery" : "Fiction",
"BookStatus" : "A" }
{ "_id" : ObjectId("661625c4b29b1b3540719643"), "Catogery" : "Non-fiction",
"BookStatus" : "A" }
{ "_id" : ObjectId("661625c4b29b1b3540719644"), "Catogery" : "Fiction",
"BookStatus" : "A" }
{ "_id" : ObjectId("661625c4b29b1b3540719646"), "Catogery" : "Fiction",
"BookStatus" : "A" }
>
>
>
>
> db.Book.find({$or:[{Catogery:'Fiction'},{BookStatus:'A'}]},
{_id:0,Catogery:1,BookStatus:1})
{ "Catogery" : "Science Fiction", "BookStatus" : "A" }
{ "Catogery" : "Fiction", "BookStatus" : "A" }
{ "Catogery" : "Fiction", "BookStatus" : "A" }
{ "Catogery" : "Non-fiction", "BookStatus" : "A" }
{ "Catogery" : "Fiction", "BookStatus" : "A" }
{ "Catogery" : "Fiction", "BookStatus" : "A" }
>
>
>
>

You might also like