mongosh
Create Collectionmongosh
There are 2 ways to create a collection.
You can create a collection using the createCollection()
database method.
You can also create a collection during the insert
process.
We are here assuming object
is a valid JavaScript object containing post data:
db.posts.insertOne(object)
Try it Yourself »
This will create the "posts" collection if it does not already exist.
Remember: In MongoDB, a collection is not actually created until it gets content!
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!