這篇文章給大家介紹MongoDB中怎么操作集合數(shù)據(jù),內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。
創(chuàng)新互聯(lián)專注于密云網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供密云營(yíng)銷型網(wǎng)站建設(shè),密云網(wǎng)站制作、密云網(wǎng)頁(yè)設(shè)計(jì)、密云網(wǎng)站官網(wǎng)定制、小程序設(shè)計(jì)服務(wù),打造密云網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供密云網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。
1.查看已有集合
show collections
2.向集合中添加數(shù)據(jù)
db.runoob.insert({
title:'test',
description:'this is description',
by:'suyanzhu',
url:'https://blog.51cto.com/suyanzhu',
tags:['php','java','mongodb'],
likes:100
})
3.查看集合中數(shù)據(jù)信息
db.runoob.find()
4.通過(guò)定義變量存儲(chǔ)數(shù)據(jù)信息,再添加到runoob集合中
document=({
"title" : "demo",
"description" : "this is description",
"by" : "yansuzhu",
"url" : "https://blog.51cto.com/suyanzhu",
"tags" : [
"php",
"sql",
"java"
],
"likes" : "100"
})
db.runoob.insert(document)
//或
db.runoob.save(document)
關(guān)于MongoDB中怎么操作集合數(shù)據(jù)就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。