> use test1
> db.emp.insert({name:"张三",age:18})
> db.emp.insertOne({name:"xz",age:25})
> db.emp.find()
> db.emp.insertMany([{name:"李四",age:20},{name:"王五",age:28}])
> db.emp.find()
var tags = ["nosql","mongodb","document","developer","popular"];
var types = ["technology","sociality","travel","novel","literature"];
var books=[];
for(var i=0;i<50;i++){
var typeIdx = Math.floor(Math.random()*types.length);
var tagIdx = Math.floor(Math.random()*tags.length);
var favCount = Math.floor(Math.random()*100);
var book = {
title: "book-"+i,
type: types[typeIdx],
tag: tags[tagIdx],
favCount: favCount,
author: "xxx"+i
};
books.push(book)
}
db.books.insertMany(books);
[root@vm-centos7-v xz]# mongo
> pwd()
> load("books.js")
> db.books.find()
> it
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://wwwxz.blog.csdn.net/article/details/124111860
内容来源于网络,如有侵权,请联系作者删除!