This commit is contained in:
2022-10-26 16:49:55 +05:30
parent cd62df8082
commit de6519c701
6 changed files with 195 additions and 48 deletions

View File

@@ -12,8 +12,8 @@ impl Mutation {
pub async fn create_book(
db: &DbConn,
form_data: book::Model,
) -> Result<book::ActiveModel, DbErr> {
book::ActiveModel {
) -> Result<InsertResult<book::ActiveModel>, DbErr> {
let record = book::ActiveModel {
open_library_key: Set(form_data.open_library_key.to_owned()),
title: Set(form_data.title.to_owned()),
edition_count: Set(form_data.edition_count.to_owned()),
@@ -27,9 +27,8 @@ impl Mutation {
rating: Set(form_data.rating.to_owned()),
comments: Set(form_data.comments.to_owned()),
..Default::default()
}
.save(db)
.await
};
Book::insert(record).exec(db).await
}
pub async fn create_book_author(