basic MONGO
Thu Sep 21 2023 11:08:27 GMT+0000 (Coordinated Universal Time)
Saved by
@prettyleka
mongod --dbpath=data - set the database and run
mongo - mongosh
db
use nucampsite
db
db.help()
Next, create a collection named campsites, and insert a new campsite document in the collection:
db.campsites.insert({ name: "React Lake Campground", description: "Test" });
Then to print out the campsites in the collection, type:
db.campsites.find().pretty();
Note the "_id" that was automatically assigned to the campsite.
Next, we will learn the information encoded into an instance of ObjectId by typing the following at the prompt:
const id = new ObjectId();
id.getTimestamp();
To exit the REPL shell, type exit at the prompt:
exit
content_copyCOPY
Comments