WIP adding interior_refs endpoints
Ran into some limitations of sqlx while trying to bulk create interior_refs. I also discovered how slow creating hundreds of rows in postgres is and I'm planning on saving interior_refs data in a jsonb column instead which seems to be much faster.
This commit is contained in:
@@ -2,6 +2,7 @@ use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use chrono::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json;
|
||||
use sqlx::postgres::PgPool;
|
||||
|
||||
use super::ListParams;
|
||||
@@ -17,6 +18,7 @@ pub struct Shop {
|
||||
pub sell_buy_list_id: i32,
|
||||
pub vendor_id: i32,
|
||||
pub vendor_gold: i32,
|
||||
pub interior_refs: serde_json::value::Value,
|
||||
pub created_at: Option<NaiveDateTime>,
|
||||
pub updated_at: Option<NaiveDateTime>,
|
||||
}
|
||||
@@ -47,8 +49,8 @@ impl Model for Shop {
|
||||
Self,
|
||||
"INSERT INTO shops
|
||||
(name, owner_id, description, is_not_sell_buy, sell_buy_list_id, vendor_id,
|
||||
vendor_gold, created_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, now(), now())
|
||||
vendor_gold, interior_refs, created_at, updated_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, now(), now())
|
||||
RETURNING *",
|
||||
self.name,
|
||||
self.owner_id,
|
||||
@@ -57,6 +59,7 @@ impl Model for Shop {
|
||||
self.sell_buy_list_id,
|
||||
self.vendor_id,
|
||||
self.vendor_gold,
|
||||
self.interior_refs,
|
||||
)
|
||||
.fetch_one(db)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user