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