All Projects → ivanceras → Rustorm

ivanceras / Rustorm

Licence: mit
an orm for rust

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Rustorm

Mikro Orm
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases.
Stars: ✭ 3,874 (+1789.76%)
Mutual labels:  orm, database, postgresql, sqlite
Typeorm
ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Stars: ✭ 26,559 (+12855.61%)
Mutual labels:  orm, database, postgresql, sqlite
Node Orm2
Object Relational Mapping
Stars: ✭ 3,063 (+1394.15%)
Mutual labels:  orm, database, postgresql, sqlite
Denodb
MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Stars: ✭ 498 (+142.93%)
Mutual labels:  orm, database, postgresql, sqlite
Linq2db
Linq to database provider.
Stars: ✭ 2,211 (+978.54%)
Mutual labels:  orm, database, postgresql, sqlite
Db
Data access layer for PostgreSQL, CockroachDB, MySQL, SQLite and MongoDB with ORM-like features.
Stars: ✭ 2,832 (+1281.46%)
Mutual labels:  orm, database, postgresql, sqlite
Go Sqlbuilder
A flexible and powerful SQL string builder library plus a zero-config ORM.
Stars: ✭ 539 (+162.93%)
Mutual labels:  orm, database, postgresql, sqlite
Piccolo
A fast, user friendly ORM and query builder which supports asyncio.
Stars: ✭ 219 (+6.83%)
Mutual labels:  orm, database, postgresql, sqlite
Old Rustorm
An ORM for rust
Stars: ✭ 168 (-18.05%)
Mutual labels:  orm, database, postgresql, sqlite
Hunt Entity
An object-relational mapping (ORM) framework for D language (Similar to JPA / Doctrine), support PostgreSQL and MySQL.
Stars: ✭ 51 (-75.12%)
Mutual labels:  orm, database, postgresql, sqlite
Bookshelf
A simple Node.js ORM for PostgreSQL, MySQL and SQLite3 built on top of Knex.js
Stars: ✭ 6,252 (+2949.76%)
Mutual labels:  orm, database, postgresql, sqlite
Entityworker.core
EntityWorker is an object-relation mapper(ORM) that enable .NET developers to work with relations data using objects. EntityWorker is an alternative to entityframwork. is more flexible and much faster than entity framework.
Stars: ✭ 91 (-55.61%)
Mutual labels:  orm, database, postgresql, sqlite
Prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB (Preview)
Stars: ✭ 18,168 (+8762.44%)
Mutual labels:  orm, database, postgresql, sqlite
Nut
Advanced, Powerful and easy to use ORM for Qt
Stars: ✭ 181 (-11.71%)
Mutual labels:  orm, database, postgresql, sqlite
Choochoo
Training Diary
Stars: ✭ 186 (-9.27%)
Mutual labels:  database, postgresql, sqlite
Ship Hold
data access framework for Postgresql on nodejs
Stars: ✭ 110 (-46.34%)
Mutual labels:  orm, database, postgresql
Next
Directus is a real-time API and App dashboard for managing SQL database content. 🐰
Stars: ✭ 111 (-45.85%)
Mutual labels:  database, postgresql, sqlite
Elefant
Elefant, the refreshingly simple PHP CMS and web framework.
Stars: ✭ 188 (-8.29%)
Mutual labels:  orm, postgresql, sqlite
Reactiveandroid
🚀 Simple and powerful ORM for Android
Stars: ✭ 102 (-50.24%)
Mutual labels:  orm, database, sqlite
Servicestack.ormlite
Fast, Simple, Typed ORM for .NET
Stars: ✭ 1,532 (+647.32%)
Mutual labels:  orm, postgresql, sqlite

Build Status

rustorm

Rustorm

Financial Contributors on Open Collective Latest Version Build Status MIT licensed

Rustorm is an SQL-centered ORM with focus on ease of use on conversion of database types to their appropriate rust type.

Selecting records

use rustorm::{
    DbError,
    FromDao,
    Pool,
    ToColumnNames,
    ToTableName,
};

#[derive(Debug, FromDao, ToColumnNames, ToTableName)]
struct Actor {
    actor_id: i32,
    first_name: String,
}

#[cfg(any(feature="with-postgres", feature = "with-sqlite"))]
fn main() {
    let mut pool = Pool::new();
    #[cfg(feature = "with-sqlite")]
    let db_url = "sqlite://sakila.db";
    #[cfg(feature = "with-postgres")]
    let db_url = "postgres://postgres:[email protected]/sakila";
    let em = pool.em(db_url).unwrap();
    let sql = "SELECT * FROM actor LIMIT 10";
    let actors: Result<Vec<Actor>, DbError> =
        em.execute_sql_with_return(sql, &[]);
    println!("Actor: {:#?}", actors);
    let actors = actors.unwrap();
    assert_eq!(actors.len(), 10);
    for actor in actors {
        println!("actor: {:?}", actor);
    }
}
#[cfg(feature="with-mysql")]
fn main() {
   println!("see examples for mysql usage, mysql has a little difference in the api");
}

Inserting and displaying the inserted records

use chrono::{
    offset::Utc,
    DateTime,
    NaiveDate,
};
use rustorm::{
    DbError,
    FromDao,
    Pool,
    TableName,
    ToColumnNames,
    ToDao,
    ToTableName,
};


#[cfg(any(feature="with-postgres", feature = "with-sqlite"))]
fn main() {
    mod for_insert {
        use super::*;
        #[derive(Debug, PartialEq, ToDao, ToColumnNames, ToTableName)]
        pub struct Actor {
            pub first_name: String,
            pub last_name: String,
        }
    }

    mod for_retrieve {
        use super::*;
        #[derive(Debug, FromDao, ToColumnNames, ToTableName)]
        pub struct Actor {
            pub actor_id: i32,
            pub first_name: String,
            pub last_name: String,
            pub last_update: DateTime<Utc>,
        }
    }

    let mut pool = Pool::new();
    #[cfg(feature = "with-sqlite")]
    let db_url = "sqlite://sakila.db";
    #[cfg(feature = "with-postgres")]
    let db_url = "postgres://postgres:[email protected]/sakila";
    let em = pool.em(db_url).unwrap();
    let tom_cruise = for_insert::Actor {
        first_name: "TOM".into(),
        last_name: "CRUISE".to_string(),
    };
    let tom_hanks = for_insert::Actor {
        first_name: "TOM".into(),
        last_name: "HANKS".to_string(),
    };

    let actors: Result<Vec<for_retrieve::Actor>, DbError> =
        em.insert(&[&tom_cruise, &tom_hanks]);
    println!("Actor: {:#?}", actors);
    assert!(actors.is_ok());
    let actors = actors.unwrap();
    let today = Utc::now().date();
    assert_eq!(tom_cruise.first_name, actors[0].first_name);
    assert_eq!(tom_cruise.last_name, actors[0].last_name);
    assert_eq!(today, actors[0].last_update.date());

    assert_eq!(tom_hanks.first_name, actors[1].first_name);
    assert_eq!(tom_hanks.last_name, actors[1].last_name);
    assert_eq!(today, actors[1].last_update.date());
}
#[cfg(feature="with-mysql")]
fn main() {
   println!("see examples for mysql usage, mysql has a little difference in the api");
}

Rustorm is wholly used by diwata

License: MIT

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].