diesel-point

Crates.iodiesel-point
lib.rsdiesel-point
version0.1.1
sourcesrc
created_at2024-02-15 01:59:44.697377
updated_at2024-02-15 12:59:17.239872
descriptionDiesel support for Point types in Postgres
homepage
repositoryhttps://github.com/fernandomarca/diesel-point
max_upload_size
id1140562
size5,507
Fernando Marca Magalhães (fernandomarca)

documentation

https://docs.rs/diesel-point

README

diesel-point   Latest Version docs

Diesel support for Point types in Postgres

Example usage

In your sql schema, you have a column some_point_field Point not null. When Diesel generates the schema (using table! {}) this column will look like some_point_field -> Point. To ensure that the Point type is in scope, read this guide and add use diesel_point::sql_types::* to the import_types key in your diesel.toml file.

E.g. it will look like this:

[print_schema]
file = "src/schema.rs"

import_types = ["diesel::sql_types::*", "diesel_point::sql_types::*"]

In your ORM struct, write some_point_field: PointXy.

Now you can use this struct / table in your diesel queries.

If your table has already been created, first run diesel migration revert. Use PointXy in the ORM struct, and then run the migration again.

Example


#[derive(Insertable, Queryable, Identifiable, Serialize, PartialEq, Debug, Clone, AsChangeset)]
#[diesel(primary_key(model_id))]
#[diesel(table_name = my_table)]
pub struct Mytable{
    pub model_id: Uuid,
    pub some_point_field: PointXy,
}

Commit count: 0

cargo fmt