user upsert
This commit is contained in:
parent
bb16fadb40
commit
a1f523f07e
Binary file not shown.
@ -22,7 +22,9 @@ class Base:
|
||||
|
||||
user = self.user()
|
||||
|
||||
store.insert_one({
|
||||
store.replace_one({
|
||||
"id": user.id
|
||||
}, {
|
||||
"id": user.id,
|
||||
"shortId": user.shortId,
|
||||
"nickname": user.nickname,
|
||||
@ -32,9 +34,10 @@ class Base:
|
||||
"followingCount": user.followInfo.followingCount,
|
||||
"followerCount": user.followInfo.followerCount
|
||||
}
|
||||
})
|
||||
}, upsert=True)
|
||||
|
||||
store.set_collection(self.instance.common.method)
|
||||
|
||||
store.insert_one({
|
||||
"msgId": self.instance.common.msgId,
|
||||
"roomId": self.instance.common.roomId,
|
||||
|
Binary file not shown.
@ -10,6 +10,9 @@ class MongoStore:
|
||||
def set_collection(self, collection):
|
||||
self.collection = self.db[collection]
|
||||
|
||||
def replace_one(self, condition, data, upsert=True):
|
||||
return self.collection.replace_one(condition, data, upsert=upsert)
|
||||
|
||||
def insert_one(self, data):
|
||||
return self.collection.insert_one(data)
|
||||
|
||||
|
Reference in New Issue
Block a user