Mongodb
Mongodb
=========================
=========================
output:-
=======
admin 40.00 KiB
config 72.00 KiB
local 88.00 KiB
students 72.00 KiB
output:-
========
switched to db dbtutorial
dbtutorial> db.createCollection("students");
=======================================
-> this command will create a new collection named "students" inside the database
dbtutorial.
output:-
========
{ ok: 1 }
dbtutorial> db.students.insertOne({name:"Aryan
Gupta",gmail:"[email protected]"});
============================================
-> this command will insert a document inside a collection
syntax:-
========
db.<collection_name>.insertOne({property:value,...});
output:-
=========
{
acknowledged: true,
insertedId: ObjectId("655c86ec381a9e8106fc1ef0")
}
dbtutorial> db.students.find();
===========================
-> this command will display all documents present inside a collection.
output:-
========
[
{
_id: ObjectId("655c86ec381a9e8106fc1ef0"),
name: 'Aryan Gupta',
gmail: '[email protected]'
},
{
_id: ObjectId("655c895b381a9e8106fc1ef1"),
name: 'Anshi Gupta',
gmail: '[email protected]'
}
]
output:-
========
[
{
_id: ObjectId("655c86ec381a9e8106fc1ef0"),
name: 'Aryan Gupta',
gmail: '[email protected]'
}
]
output:-
=========
[
{
_id: ObjectId("655c895b381a9e8106fc1ef1"),
name: 'Anshi Gupta',
gmail: '[email protected]'
},
{
_id: ObjectId("655c8b00381a9e8106fc1ef2"),
name: 'Anshi Gupta',
gmail: '[email protected]'
}
]