ما هو MongoDB؟
الـ MongoDB هي قاعدة بيانات NoSQL موجهة document-oriented تستخدم لتخزين بيانات valume data بدلاً من استخدام table و rows كما هو الحال في relational databses التقليدية ، تستخدم MongoDB الـ collections و الـ documents .
ما هي collections و documents ؟
الـ Documents : تتكون من key-value وهي unit للبيانات في MongoDB.
الـ Collections : تحتوي على مجموعات من Documents و functions التي تعادل relational database tables .
15 امر في MonogDB من الاوامر المهم و الاساسية :
1.Enlist available databases
→ Show db
2 . To Create a new DB
→ use db-name
3 . See your current working directry
→ db
4 . Delete Database
db.mydb.drop()
5 . Create User
-> db.createUser({
user:'admin',
pws:'root',
roles:["readWrite", "dbAdmin"]
})
6 . Creating Collections
-> db.createCollection('customers');
7 . Showing Collections
-> show collections
8 . Inserting values into collections
-> db.customers.insert({first_name:"shubham", last_name:"Athawane"});
9 . View Collection Records
-> db.customers.find();
//And
-> db.customers.find().pretty();
//Note: pretty() will show you result in json formate
10 . Add new Document in Collections
-> db.customers.insert([{"first_name":"Virat", "last_name":"Kohli"},
{"first_name":"Taylor", "last_name":"Swift"}])
// And -> $set, $inc, $unset
-> db.customers.update({first_name:"Glen"}, {$set:{age:45}})
11 . Rename Document
-> db.customers.update({first_name:"Virat"}, {$rename:{"age":"old"}})
12 . Remove document
-> db.customers.remove({first_name:"Joe"})
13 . find the matching
-> db.customers.findOne({first_name:"Joe"})
14 . Count Rows
-> db.customers.count()
15 . This is Less than/Greater than/ Less than or Eq/Greater than or Eq operators
db.customers.find({age: {$lt: 90}})
db.customers.find({age: {$lte: 90}})
db.customers.find({age: {$gt: 90}})
db.customers.find({age: {$gte: 90}})
>>Click here to continue<<