MongoDB 中,只有在獲取內容後才會真正建立集合! ## 建立資料庫 ``` use <name> ``` ## 建立集合 ``` db.createCollection(<name>) ``` ## 查看集合 ``` show collections ``` ## 插入 ``` db.posts.insertOne({ title: "Post Title 1", body: "Body of post.", category: "News", likes: 1, tags: ["news", "events"], date: Date() }) ```  ## 查找 ``` db.posts.find() ```  ## 更新第一筆 ``` db.posts.updateOne( { title: "Post Title 1" }, { $set: { likes: 2 } } ) ```  ## 刪除第一筆 ``` db.posts.deleteOne({ title: "Post Title 5" }) ``` 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up