diesel-sqlite-struct-json-text

Crates.iodiesel-sqlite-struct-json-text
lib.rsdiesel-sqlite-struct-json-text
version0.1.2
created_at2025-06-06 12:27:14.088257+00
updated_at2025-06-09 13:53:59.285525+00
descriptionThis proc macro attribute will allow you to store the target struct as json in TEXT field in diesel sqlite.
homepagehttps://github.com/Salman-Sali/diesel-sqlite-struct-json-text
repository
max_upload_size
id1702959
size6,094
(Salman-Sali)

documentation

README

Your cargo.toml

[dependencies]
diesel = { version="*", features= ["sqlite"]}
serde = {version = "*", features = ["derive"]}
serde_json = "*"

The target struct

#[diesel_sqlite_struct_json_text]
pub struct MyJson {
    pub my_item: String,
    pub my_item_2: i32
}

The database entity

#[diesel(table_name = crate::schema::my_entity)]
#[derive(Debug, Queryable, Selectable, Identifiable, Associations, PartialEq, Insertable)]
pub struct MyEntity {
    pub id: i32,
    pub my_json: MyJson
}

The schema

diesel::table! {
    my_entity (id) {
        id -> Integer,
        my_json -> Text
    }
}
Commit count: 0

cargo fmt