db.post.find(); { _id : ObjectId( 54a51cfd7f46906f81b7adcd ), ba..."/>
您好,登錄后才能下訂單哦!
先看集合post中文檔信息:
> db.post.find(); { "_id" : ObjectId("54a51cfd7f46906f81b7adcd"), "bar" : "baz" } { "_id" : 0 } { "_id" : 1 } { "_id" : 2 } { "_id" : 5, "test1" : 0 } { "_id" : 4, "test2" : 2 } { "_id" : 3, "test3" : 3 } { "_id" : 6, "test5" : 5 } { "_id" : 7, "test1" : 1 } { "_id" : 8, "test1" : 1 }
刪除指定的文檔:
> db.post.remove({"_id":5}); WriteResult({ "nRemoved" : 1 }) > db.post.find(); { "_id" : ObjectId("54a51cfd7f46906f81b7adcd"), "bar" : "baz" } { "_id" : 0 } { "_id" : 1 } { "_id" : 2 } { "_id" : 4, "test2" : 2 } { "_id" : 3, "test3" : 3 } { "_id" : 6, "test5" : 5 } { "_id" : 7, "test1" : 1 } { "_id" : 8, "test1" : 1 }
刪除所有{“test1”:1}的文檔:
> db.post.remove({"test1":1}); WriteResult({ "nRemoved" : 2 }) > db.post.find(); { "_id" : ObjectId("54a51cfd7f46906f81b7adcd"), "bar" : "baz" } { "_id" : 0 } { "_id" : 1 } { "_id" : 2 } { "_id" : 4, "test2" : 2 } { "_id" : 3, "test3" : 3 } { "_id" : 6, "test5" : 5 } >
刪除整個(gè)post集合:
> db.post.drop() true > show collections system.indexes >
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。