on Debian 基本使用
Last updated
>db.class100.insert({"stu":1,"name":"王小明","age":13})
WriteResult({ "nInserted" : 1 })
>show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
mydatabase 0.000GB
> show collections
class100> db.class100.insert({"stu":2,"name":"林小美","age":13})
WriteResult({ "nInserted" : 1 })
> db.class100.find()
{ "_id" : ObjectId("5de6fef4ea717dbacb7553c6"), "stu" : 1, "name" : "王小明", "age" : 13 }
{ "_id" : ObjectId("5de6fff8ea717dbacb7553c7"), "stu" : 2, "name" : "林小美", "age" : 13 }
#_id為預設主鍵,會自動補上> db.class100.find({"stu":1})
{ "_id" : ObjectId("5de6fef4ea717dbacb7553c6"), "stu" : 1, "name" : "王小明", "age" : 13 }
> db.class100.find({"name":"林小美"})
{ "_id" : ObjectId("5de6fff8ea717dbacb7553c7"), "stu" : 2, "name" : "林小美", "age" : 13 }