D:\mongodb\Server\3.4\bin>mongo
MongoDB shell version v3.4.4
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.4
#使用tutorial数据库
> use tutorial
switched to db tutorial
#插入数据
> {username:"smith"}
smith
#插入
> db.users.insert({username:"smith"})
WriteResult({ "nInserted" : 1 })
#查询
> db.users.find()
{ "_id" : ObjectId("595123c02e90d9c2345d28ff"), "username" : "smith" }
> db.users.insert({username:"jones"})
WriteResult({ "nInserted" : 1 })
#
> db.users.count()
2
> db.users.find({ $and:[{ username:"smith"}, {username:"jones"}] })
> db.users.find({ $or:[{ username:"smith"}, {username:"jones"}] })
{ "_id" : ObjectId("595123c02e90d9c2345d28ff"), "username" : "smith" }
{ "_id" : ObjectId("5951245a2e90d9c2345d2900"), "username" : "jones" }
>