meuter / miniorm-rs Goto Github PK
View Code? Open in Web Editor NEWa *very* simple ORM built on top of sqlx.
License: MIT License
a *very* simple ORM built on top of sqlx.
License: MIT License
Implementing a REST axum router (#9) directly on top of Store
is probably not a good idea. What if someone wants to use the use the Router on some other data structure that provides CRUD operations. One should be able to to that.
Rust's answer to that is to define a Crud
trait that contains all of the necessary functions and build a router on any type that implements this trait.
SELECT COUNT(*) FROM {table}
Multiple issues to figure out to integrate the MySql backend:
?
(supported by MySql and Sqlite) vs $i
(supported by Sqlite and Postgres)RETURNING id
in the create and update query. Sqlx has last_insert_id()
method on MySqlQueryResult
, unclear if this works for UPDATE queries. But that means that we need to use a Query
, not a QueryAs
so the Bind
trait is notsuitable as is because it only allows to bind against QueryAs
Given a Store
that implements all the necessary CRUD operations, one should be able to create an axum::Router
that handles all of these operations over a REST API, provided of course the the entity type implemented serde::Serialize
and serde::Deserialize
.
GET /
will list all entities,POST /
will create a new entity,PUT /
will update an existing entity,DELETE /
will delete all entitiesGET /:id
to retrieve one entity from the storePUT /:id
to update one entity in the storePATCH /:id
to update one entity in the store - PATH or PUT or both?DELETE /:id
to delete one entity from the storeThe main issue here is that on top of having to serialize/deserialize the entities, we also need a way to pack the id returned by the database. Introducing a wrapper type WithId<E,I> { inner: E, id: I }
might be a good option here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.