Code Monkey home page Code Monkey logo

ormx's Introduction

ormx

lightweight macros for sqlx

getting started

Add ormx and sqlx to your Cargo.toml

[dependencies.ormx]
version = "0.7"
features = ["mysql"]

[dependencies.sqlx]
version = "0.5"
default-features = false
features = ["macros", "mysql", "runtime-tokio-rustls"]

Right now, ormx supports mysql/mariadb and postgres.

what does it do?

ormx provides macros for generating commonly used sql queries at compile time.
ormx is meant to be used together with sqlx. Everything it generates uses sqlx::query! under the hood, so every generated query will be checked against your database at compile time.

what doesn't it do?

ormx is not a full-fledged ORM nor a query builder. For everything except simple CRUD, you can always just use sqlx.

it is required that every table contains an id column, which uniquely identifies a row. probably, you would want to use an auto-incrementing integer for this. this is a central requirement of ormx, and if your table does not fulfill this requirement, ormx is not what you are looking for.

help

if you encounter an issue or have questions, feel free to ask in #ormx on the sqlx discord.
The documentation currently is not what it should be, so don't be afraid to ask for help.

features

  • mysql - enable support for mysql/mariadb
  • postgres - enable support for postgres

migration guide for 0.7

Since 0.7, id columns are not special anymore - if they are generated by the database, you must annotete them with #[ormx(default)].

a note on reborrowing

if you run into the issue that the compiler tells you that you can't re-use a &mut Connection because

  • use of moved value and
  • move occurs because 'con' has type '&mut Connection', which does not implement the 'Copy' trait

you'll have to manually reborrow the connection with &mut *con.

ormx's People

Contributors

bram209 avatar clouds56 avatar nyxcode avatar otak avatar punie avatar

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.