rusty-postgres 0.1.2-beta

A advanced lightwight ORM and Query Builder for postgres
Documentation
rusty-postgres-0.1.2-beta has been yanked.

License Crates.io

A Advanced Lightwight ORM and Query Builder for postgres

Usage

Client

  let mut postgres = Client::connect("host=127.0.0.1 port=5432 dbname=name user=postgres password=xxxxxxxxx connect_timeout=10 sslmode=prefer", NoTls);

Create Schema without any hassale

  let shop = model! {
        "shop" => {
            "id" => {
                ID(UUID),NOTNULL,UNIQUE
            },
            "name" => {
                Date(NOW)
            },
            "time" => {
                Time(NOW)
            },
            "fingerprint" => {
                DateTime(NOW)
            },
            "age" => {
                NUMBER,DEFAULT(24)
            },
            "place" => {
                STRING,NOTNULL,UNIQUE,INDEX,PRIMARY
            },
            "location" => {
                Geography(POINT(Epsg4326))
            }
            "accuracy" => {
                FLOAT,DEFAULT(0.0)
            },
            "bool" => {
                BOOL
            }
        },
        partition:{
            type:"list",
            to:"place"
        }
    };

Container

Build Schema

  let container = container! {
      client =>  postgres,
      models => {
        shop
      }
  };

Create

    let create = create! {
        connection => postgres,
        model:"user_",
        data:{
            "story" => "billionairehari",
            "age" => 24 as i32
        },
        select:{
            "id"
        }
    };

FindOne

  let find = find_one! {
      connection => postgres,
      model:"elonmusk",
      select:{
          "id"
      },
      condition:{
          "story" => "billionairehari"
      }
  };

FindMany

  let find = find_many! {
      connection => postgres,
      model:"elonmusk",
      conditions:{
          or => {
              "story" => "haribillionaire"
          },
          "story" => "haribillionaire"
      },
      limit:4
  };

Update

  let update = update! {
      connection => postgres,
      model:"elonmusk",
      select:{
          "story"
      },
      data:{
          "story" => "billionairehari"
      },
      conditions:{
          "story" => "billionaires"
      }
    };

Delete

  let delete = delete! {
      connection => postgres,
      model:"elonmusk",
      conditions:{
          "story" => "billionairehari"
      },
      select:{
          "story"
      }
    };

DROP

  delete_table! {
      connection => postgres,
      model => "photo",
      cascade
  }
  .unwrap();