diesel-mysql-spatial

Crates.iodiesel-mysql-spatial
lib.rsdiesel-mysql-spatial
version0.1.2
sourcesrc
created_at2022-05-16 02:33:38.14739
updated_at2022-05-17 00:28:15.307294
descriptionAn extension for the Diesel framework to support MySQL spatial datatypes.
homepage
repositoryhttps://gitlab.com/cg909/diesel-mysql-spatial
max_upload_size
id587414
size57,586
(cgrenz)

documentation

README

diesel-mysql-spatial - An extension for the Diesel framework to support MySQL spatial datatypes

Crates.io Documentation License

Usage

  1. Add the following to your Cargo.toml:
[dependencies]
diesel-mysql-spatial = "0.1"
  1. Read the crate documentation

Example

Assuming a MySQL table defined like this

CREATE TABLE districts (
    id         INTEGER NOT NULL PRIMARY KEY,
    center     POINT NOT NULL,
    area       POLYGON NOT NULL
);

then the Rust code may look like this:

use diesel_mysql_spatial::data_types::{Point, Polygon};

#[derive(Insertable, Queryable)]
#[table_name = "districts"]
struct District {
    id: i32,
    center: Point,
    area: Polygon,
}

table! {
    use diesel_mysql_spatial::sql_types::*;
    use diesel::sql_types::*;
    districts (id) {
        id -> Integer,
        center -> Point,
        area -> Polygon,
    }
}

Stability

This crate follows semantic versioning with the additional promise that below 1.0.0 backwards-incompatible changes will not be introduced with only a patch-level version number change.

License

Licensed under Mozilla Public License, Version 2.0 (LICENSE or https://www.mozilla.org/en-US/MPL/2.0/).

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above including compatibility with secondary licenses, as defined by the MPL.

Commit count: 8

cargo fmt