mirror of
https://github.com/Start9Labs/patch-db.git
synced 2026-03-30 12:01:57 +00:00
fix option get_mut
This commit is contained in:
@@ -210,7 +210,10 @@ impl<T: HasModel + Serialize + for<'de> Deserialize<'de>> OptionModel<T> {
|
|||||||
Ok(ModelData(db.get(self.0.as_ref()).await?))
|
Ok(ModelData(db.get(self.0.as_ref()).await?))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_mut<Db: DbHandle>(&self, db: &mut Db) -> Result<ModelDataMut<T>, Error> {
|
pub async fn get_mut<Db: DbHandle>(
|
||||||
|
&self,
|
||||||
|
db: &mut Db,
|
||||||
|
) -> Result<ModelDataMut<Option<T>>, Error> {
|
||||||
self.lock(db, LockType::Write).await;
|
self.lock(db, LockType::Write).await;
|
||||||
let original = db.get_value(self.0.as_ref(), None).await?;
|
let original = db.get_value(self.0.as_ref(), None).await?;
|
||||||
let current = serde_json::from_value(original.clone())?;
|
let current = serde_json::from_value(original.clone())?;
|
||||||
|
|||||||
Reference in New Issue
Block a user