Coder Social home page Coder Social logo

debil's Introduction

debil debil at crates.io

ORM aims to provide Table macro and auto migration

Table macro

You need to specify sql_type to be something that each DB crate provides.

#[derive(Table)]
#[sql(table_name = "ex_1", sql_type = "...", primary_key = "pk")]
struct Ex1 {
    #[sql(size = 50, unique = true, not_null = true)]
    field1: String,
    aaaa: i32,
    pk: i32,
}

This example derives some useful mapper functions for this struct. See functions in debil's docs.

Accessor macro

Accessor macro provides safe way to access to each column. This is useful for constructing a query.

// Use Accessor derive here!
#[derive(Table, Accessor)]
#[sql(table_name = "ex_1", sql_type = "...", primary_key = "pk")]
struct Ex1 {
    field1: String,
    aaaa: i32,
    pk: i32,
}

// Use accessor! macro to access to a field with table_name prefixed
assert_eq!(accessor!(Ex1::field1), "ex_1.field1");

// If you only need field name, use accessor_name! macro
assert_eq!(accessor_name!(Ex1::aaaa), "aaaa");

// Or you can just call the field name function directly, which is derived by Accessor derive
assert_eq!(Ex1::field1(), "field1");

// accessor!(Ex1::foobar) <- compile error!

debil's People

Contributors

myuon avatar tawashichan avatar

Stargazers

Akihito KIRISAKI avatar Rust avatar

Watchers

James Cloos avatar keno (Ken Okada) avatar  avatar

Forkers

tawashichan

debil's Issues

Reorganize

  • Handle dbs in debil crate with feature gates
  • CamelCases for traits
  • Complete raw io for sql_* methods and higher APIs for other methods
  • Supports for sqlite
  • Remove unused modules such as binary
  • Stop specifying sql_type
  • v0.5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.