$set instead of overwriting object

This commit is contained in:
Paul Makles
2021-01-24 10:28:24 +00:00
parent 11f7092fcd
commit 99e2f874a1

View File

@@ -51,11 +51,13 @@ impl Message {
channels.update_one( channels.update_one(
doc! { "_id": id }, doc! { "_id": id },
doc! { doc! {
"active": true, "$set": {
"last_message": { "active": true,
"_id": self.id.clone(), "last_message": {
"author": self.author.clone(), "_id": self.id.clone(),
"short": self.content.chars().take(24).collect::<String>() "author": self.author.clone(),
"short": self.content.chars().take(24).collect::<String>()
}
} }
}, },
None None
@@ -70,10 +72,12 @@ impl Message {
channels.update_one( channels.update_one(
doc! { "_id": id }, doc! { "_id": id },
doc! { doc! {
"last_message": { "$set": {
"_id": self.id.clone(), "last_message": {
"author": self.author.clone(), "_id": self.id.clone(),
"short": self.content.chars().take(24).collect::<String>() "author": self.author.clone(),
"short": self.content.chars().take(24).collect::<String>()
}
} }
}, },
None None