Tải bản đầy đủ (.pdf) (1 trang)

013 exercise file updated tủ tài liệu training

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (53.16 KB, 1 trang )

1) Creating First Database
//below is the syntax for creating database. Here database name is m
​ yblogs
use myblogs;
// creating first ​collection ​in the database m
​ yblogs​. Here, ​collection ​name is
“​articles​”
db.articles.insert({name : “mongoDB intro”, category :“database”,
tags : [“nosql”,”db”,”bigdata”]});
// querying a collection
db.articles.find().pretty();
// creating a ​document ​and saving to collection
var ​articleInfo ​={};
articleInfo​.articleName= “MongoDB Introduction”;
articleInfo​.authorName =”Sunil G”;
articleInfo​.tags = [“database”,“NoSQL”,”DBA”,“DEV”];
// saving a document to collection
db.​articles​.save(​articleInfo​);
P.S: in the above example,
Database Name: ​myblogs
Collection Name:​articles
Document Name: ​articleInfo



×