mongoDB ???????
???????????? ???????[ 2016/10/25 10:05:31 ] ????????????? mongoDB
????mongoDB???????????£????????????????£???????????????????????(?У???????????????????????????????????ν????????????????????????????mongoDB?????????£?????????滻???????????mongoDB?????????????
???????????
????Linux???????MongoDB
????Windows???°??MongoDB
????mongoDB ???????
????mongo shell?????mongoDB??shell??????????js???
????mongoDB??鼰???????
????SQL??mongoDB???????
????????????????
????db.collection.update(
????<query>?? //????????????
????<update>?? //?????(????????????)
????{
????upsert: <boolean>?? //?true????false??????true??δ??????????????????
????multi: <boolean>?? //??????????л????????????(true???????)
????writeConcern: <document> //?趨д????????????????????????????
????} //?????3.2?????????????????
????)
????db.collection.updateOne( //??3.2???汾
????<filter>??
????<update>??
????{
????upsert: <boolean>??
????writeConcern: <document>
????}
????)
????db.collection.updateMany( //??3.2???汾
????<filter>??
????<update>??
????{
????upsert: <boolean>??
????writeConcern: <document>
????}
????)
????db.collection.replaceOne( //??3.2???汾???????滻???
????<filter>??
????<replacement>??
????{
????upsert: <boolean>??
????writeConcern: <document>
????}
????)
???????????????
????mongoDB??????д?????????????????????????????(3.2?汾??)
????_id???????£??????????????????_id????????滻
???????????????????????????????????????μ??????
??????????????????
????1??db.collection.updateOne()
????//???????
????db.version()
????3.2.9
????//???????????????????ο???mongoDB?????? ??????????????
????//?????? http://blog.csdn.net/leshami/article/details/52901240
????//??????favorites.artist??Picasso?????
????> db.users.find({"favorites.artist": "Picasso"}??
????{finished:0??points:0??badges:0}).pretty()
????{
????"_id" : 1??
????"name" : "sue"??
????"age" : 19??
????"type" : 1??
????"status" : "P"??
????"favorites" : {
????"artist" : "Picasso"??
????"food" : "pizza"
????}
????}
????{
????"_id" : 6??
????"name" : "abc"??
????"age" : 43??
????"type" : 1??
????"status" : "A"??
????"favorites" : {
????"food" : "pizza"??
????"artist" : "Picasso"
????}
????}
????//?????favorites.artist??Picasso????????и???
????//???$set???????????????е????????????favorites.food???pie????type??3
????//???$currentDate?????????lastModified??????????
????> db.users.updateOne(
????{ "favorites.artist": "Picasso" }??
????{
????$set: { "favorites.food": "pie"?? type: 3 }??
????$currentDate: { lastModified: true }
????}
????)
????{ "acknowledged" : true?? "matchedCount" : 1?? "modifiedCount" : 1 }
????//??????????????
????> db.users.find({"favorites.artist": "Picasso"}??
????{finished:0??points:0??badges:0}).pretty()
????{
????"_id" : 1?? //?????????????????????????
????"name" : "sue"??
????"age" : 19??
????"type" : 3??
????"status" : "P"??
????"favorites" : {
????"artist" : "Picasso"??
????"food" : "pie"
????}??
????"lastModified" : ISODate("2016-09-30T07:25:28.135Z")
????}
????{
????"_id" : 6?? //??_id?6??????????б???????updateOne????????????????
????"name" : "abc"??
????"age" : 43??
????"type" : 1??
????"status" : "A"??
????"favorites" : {
????"food" : "pizza"??
????"artist" : "Picasso"
????}
????}
????2??db.collection.updateMany()
????//???????favorites.artist??Picasso???????
????//???μ??????favorites.artist??Pisanello??type????3????????????lastModified???
????> db.users.updateMany(
????{ "favorites.artist": "Picasso" }??
????{
????$set: { "favorites.artist": "Pisanello"?? type: 3 }??
????$currentDate: { lastModified: true }
????}
????)
????{ "acknowledged" : true?? "matchedCount" : 2?? "modifiedCount" : 2 } //????????2??????????????????2
????//??β??favorites.artist??Picasso??????????????κ?????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11