Group B Assignment No: 10 Class: T.E. Computer Roll No
Group B Assignment No: 10 Class: T.E. Computer Roll No
Assignment No: 10
Class: T.E. Computer Roll No:
Problem Statement:
Design and Develop MongoDB Queries using CRUD operations. (Use CRUD operations,
SAVE method, logical operators)
Objective:
1. To learn and understand NOSQL Databas..
2. To execute CRUD Operations using SAVE Method & Logical Operators.
Hardware requirements:
Any CPU with Pentium Processor or similar, 256 MB
RAM or more, 1 GB Hard Disk or more.
Software requirements:
Ubuntu 14.04, MongoDB Packages.
Theory:
Syntax
The basic syntax of MongoDB save() method is shown below −
>db.COLLECTION_NAME.save({_id:ObjectId(),NEW_DATA})
Example
Following example will replace the document with the _id '5983548781331adf45ec7'.
>db.mycol.save(
{
"_id" : ObjectId(5983548781331adf45ec7), "title":"Test1",
"by":"JIT"
}
)
>db.mycol.find()
{ "_id" : ObjectId(5983548781331adf45ec5), "title":"New Topic",
"by":"DBMSTutor"}
{ "_id" : ObjectId(5983548781331adf45ec6), "title":"NoSQL Overview"}
{ "_id" : ObjectId(5983548781331adf45ec7), "title":"Test1",”by” : ”JIT”}
>
save()method performs an insert since the document passed to the method does not contain
the_idfield. During the insert, the shell will create the _id field with a unique ObjectId value, as
verified by the inserted document.
Name Description
$and Joins query clauses with a logical AND returns all documents that match the conditions of
both clauses.
$not Inverts the effect of a query expression and returns documents that do not match the query
expression.
$nor Joins query clauses with a logical NOR returns all documents that fail to match both clauses.
$or Joins query clauses with a logical OR returns all documents that match the conditions of
either clause
e.g.
This query will select all documents in the inventory collection where:
db.inventory.find( {
$and : [
})
Conclusion: