1use crate::traits::model::Model;
2use chrono::{DateTime, Utc};
3use diesel::{AsChangeset, Insertable, Queryable, Selectable};
4use serde::{Deserialize, Serialize};
5
6#[derive(
7 Debug, Default, Serialize, Deserialize, Clone, PartialEq, Queryable, Selectable, AsChangeset,
8)]
9#[diesel(table_name = crate::schema::fish_ponds)]
10#[diesel(check_for_backend(diesel::pg::Pg))]
11pub struct Pond {
12 pub id: i64,
14 pub user_id: i64,
16 pub created_at: DateTime<Utc>,
18 pub updated_at: DateTime<Utc>,
20 pub capacity: i32,
22}
23
24impl Model for Pond {
25 type Table = crate::schema::fish_ponds::table;
26 type PrimaryKeyType = i64;
27 type InsertType = NewPond;
28
29 fn table() -> Self::Table {
30 crate::schema::fish_ponds::table
31 }
32
33 fn id(&self) -> Self::PrimaryKeyType {
34 self.id
35 }
36}
37
38#[derive(Insertable)]
39#[diesel(table_name = crate::schema::fish_ponds)]
40#[diesel(check_for_backend(diesel::pg::Pg))]
41pub struct NewPond {
42 pub user_id: i64,
43 pub capacity: i32,
44}