Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions wither/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ where
/// write concern.
async fn save(&mut self, db: &Database, filter: Option<Document>) -> Result<()> {
let coll = Self::collection(db);
let instance_doc = Self::document_from_instance(&self)?;
let instance_doc = Self::document_from_instance(self)?;

// Ensure that journaling is set to true for this call, as we need to be able to get an ID back.
let mut write_concern = Self::write_concern().unwrap_or_default();
Expand All @@ -180,7 +180,7 @@ where
(Some(id), _) => doc! {"_id": id},
(None, None) => {
let new_id = ObjectId::new();
self.set_id(new_id.clone());
self.set_id(new_id);
doc! {"_id": new_id}
}
(None, Some(filter)) => {
Expand All @@ -202,8 +202,10 @@ where

// Update instance ID if needed.
if id_needs_update {
let response_id = updated_doc.get_object_id("_id").map_err(|_| WitherError::ServerFailedToReturnObjectId)?;
self.set_id(response_id.clone());
let response_id = updated_doc
.get_object_id("_id")
.map_err(|_| WitherError::ServerFailedToReturnObjectId)?;
self.set_id(response_id);
};
Ok(())
}
Expand Down Expand Up @@ -322,7 +324,7 @@ where
/// defined in this model's `indexes` method.
async fn sync(db: &Database) -> Result<()> {
let coll = Self::collection(db);
let current_indexes = get_current_indexes(&db, &coll).await?;
let current_indexes = get_current_indexes(db, &coll).await?;
sync_model_indexes(db, &coll, Self::indexes(), current_indexes).await?;
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion wither_derive/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl<'a> MetaModel<'a> {

/// Extract any model attrs and bind them to their optional slots.
fn extract_model_attrs(&mut self) {
let attrs = Self::parse_attrs(&self.attrs, MODEL_HELPER_ATTR);
let attrs = Self::parse_attrs(self.attrs, MODEL_HELPER_ATTR);
// Parse over the internals of our `model` attrs. At this point, we are dealing with
// individual elements inside of the various `model(...)` attrs.
for attr_meta in attrs {
Expand Down