Use user
Db
Show DBS
Db.dropdatabase ()
Db. Collection_name.insert (document)
Exp:
Db.user.insert ({name: "user1", Password: "123456"})
Hint: Writeresult ({"ninserted": 1}) indicates successful insertion
Db.user.find ()
Hint {"_id": ObjectId ("56946FBA3A18F4867AECBCD1"), "name": "user1", "Password": "
123456 "}
> test={name: "user2", Passsword: "123456"}
{"Name": "User2", "Passsword": "123456"}
> Db.user.insert (Test)
Writeresult ({"ninserted": 1})
> Db.user.find ()
{"_id": ObjectId ("56946FBA3A18F4867AECBCD1"), "name": "user1", "Password": "
123456 "}
{"_id": ObjectId ("5694714A3A18F4867AECBCD2"), "name": "User2", "Passsword":
"123456"}
Insert document You can also use the Db.col.save command. If you do not specify the _id field, the Save () method is similar to the Insert () method. If the _id field is specified, the data for the _id is updated.
Learning MONGO Series (ii) New database, collection, insert (), Save ()