make CallbackInfo::store to consume self and return
This commit is contained in:
parent
a00c0017bb
commit
58a16a5927
@ -1,4 +1,4 @@
|
||||
use crate::query_call;
|
||||
use crate::query_call_consume;
|
||||
use crate::CallDB;
|
||||
use bson::oid::ObjectId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -31,13 +31,13 @@ where
|
||||
self._id.to_hex()
|
||||
}
|
||||
|
||||
query_call!(store, self, db, (), {
|
||||
query_call_consume!(store, self, db, Self, {
|
||||
let db = db.get_database().await;
|
||||
let ci = db.collection::<Self>("callback_info");
|
||||
|
||||
ci.insert_one(self).await?;
|
||||
ci.insert_one(&self).await?;
|
||||
|
||||
Ok(())
|
||||
Ok(self)
|
||||
});
|
||||
|
||||
pub async fn get<D: CallDB>(db: &mut D, id: &str) -> DbResult<Option<Self>> {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use super::super::{callback_info::CallbackInfo, CallDB, DB};
|
||||
use super::super::callback_info::CallbackInfo;
|
||||
use super::setup_db;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -20,7 +20,7 @@ async fn test_store() {
|
||||
|
||||
let ci = CI::new(Default::default());
|
||||
|
||||
ci.store(&mut db).await.unwrap();
|
||||
let ci = ci.store(&mut db).await.unwrap();
|
||||
|
||||
let ci = CI::get(&mut db, &ci.get_id()).await.unwrap();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user