CRUD example with Rocket, Toql and MySQL

Related tags

Database todo_rotomy
Overview

Todo (Rocket, Toql, MySQL)

This is a little REST server built with Rocket, Toql and MySQL.

The server allows to call CRUD functions on a Todo item.

It demonstrates how easy it is to write REST backends with the Rust programming language.

Get it running

You need a running MySQL server to play around with it.

Then create the database todo_rotomy and insert the Todo table with

CREATE TABLE `Todo` (`id` int(11) NOT NULL AUTO_INCREMENT,`title` varchar(200) NOT NULL, `completed` tinyint(1) DEFAULT 0, PRIMARY KEY (`id`))` 

Now clone this repository

git clone https://github.com/roy-ganz/todo_rotomy.git

Run the server with your database username and password

ROCKET_DATABASES='{todo_rotomy={url=mysql://USER:[email protected]:3306/todo_rotomy}}' cargo run

Use the server

Open another terminal and use curl:

Insert a new item

curl localhost:8000/todo -X POST -d '{\"title\":\"Water plants\"}'

Update an item

curl localhost:8000/todo/ID -X PUT -d '{\"completed\":\"true\"}'

List all todo items

curl localhost:8000/todo

Get a single item

curl localhost:8000/todo/ID

Get only completed todos in descending order (example of Toql query)

curl localhost:8000/todo?query=-id,completed+eq+1

Delete an item

curl -X DELETE localhost:8000/todo/ID

Make your own

This project may also serve as a starting point for your own REST server.

However if you plan a big project, it's important to split up your Rust project into separate crates to keep compilation time sane. The #[derive(Toql) adds a lot of code to your structs.

License

Todo-rotomy is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

You might also like...
Gibbs MySQL Spyglass
Gibbs MySQL Spyglass

Gibbs MySQL Spyglass Ahoy Matey! The Gibbs MySQL Spyglass is a application used to capture application traffic into a MySQL database. It is designed t

rust-mysql-simple support library for the r2d2 connection pool

r2d2-mysql rust-mysql-simple support library for the r2d2 connection pool.

Example sqlite3 Dynamic Loadable Extension in Rust - vfs and vtab modules - port of vfsstat.c

Example sqlite3 Dynamic Loadable Extension in Rust - vfs and vtab modules The vfs and vtab This is a port of the official ext/misc/vfsstat.c sqlite3 e

Rust and TypeScript example code for finding all members from a collection id.

get-collection-rs Use the Crawler cargo build --release ./target/release/get-collection rpc_node collection_id Example: ./target/release/get-col

A place for the community to upload example Scrypto code

community-scrypto A place for the community to upload example Scrypto code. Please fork from main, work out of a sub-directory of your choosing, and t

Skybase is an extremely fast, secure and reliable real-time NoSQL database with automated snapshots and SSL
Skybase is an extremely fast, secure and reliable real-time NoSQL database with automated snapshots and SSL

Skybase The next-generation NoSQL database What is Skybase? Skybase (or SkybaseDB/SDB) is an effort to provide the best of key/value stores, document

Simple and handy btrfs snapshoting tool. Supports unattended snapshots, tracking, restoring, automatic cleanup and more. Backed with SQLite.
Simple and handy btrfs snapshoting tool. Supports unattended snapshots, tracking, restoring, automatic cleanup and more. Backed with SQLite.

Description Simple and handy btrfs snapshoting tool. Supports unattended snapshots, tracking, restoring, automatic cleanup and more. Backed with SQLit

Skytable is an extremely fast, secure and reliable real-time NoSQL database with automated snapshots and TLS
Skytable is an extremely fast, secure and reliable real-time NoSQL database with automated snapshots and TLS

Skytable is an effort to provide the best of key/value stores, document stores and columnar databases, that is, simplicity, flexibility and queryability at scale. The name 'Skytable' exemplifies our vision to create a database that has limitless possibilities. Skytable was previously known as TerrabaseDB (and then Skybase) and is also nicknamed "STable", "Sky" and "SDB" by the community.

asynchronous and synchronous interfaces and persistence implementations for your OOD architecture

OOD Persistence Asynchronous and synchronous interfaces and persistence implementations for your OOD architecture Installation Add ood_persistence = {

Owner
Artos
Artos
CRUD system of book-management with ORM and JWT for educational purposes.

Book management English | 中文 Required Rust MySQL 5.7 Usage Execute init.sql to create tables. Set environment variable DATABASE_URL and JWT_SECRET in

null 32 Dec 28, 2022
The most efficient, scalable, and fast production-ready serverless REST API backend which provides CRUD operations for a MongoDB collection

Optimal CRUD Mongo Goals of This Project This is meant to be the most efficient, scalable, and fast production-ready serverless REST API backend which

Evaluates2 1 Feb 22, 2022
Grsql is a great tool to allow you set up your remote sqlite database as service and CRUD(create/read/update/delete) it using gRPC.

Grsql is a great tool to allow you set up your remote sqlite database as service and CRUD (create/ read/ update/ delete) it using gRPC. Why Create Thi

Bruce Yuan 33 Dec 16, 2022
A CRUD library for Holochain zomes that implements the CAPS pattern (Chained, Action ID, Permalink, State-based)

Holochain CRUD Library (CAPS pattern) A CRUD library for Holochain zomes that implement the CAPS pattern (Chained, Action, Permalink, State-based) Hol

Matthew Brisebois 3 Dec 3, 2022
🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, SQLite, and MSSQL.

SQLx ?? The Rust SQL Toolkit Install | Usage | Docs Built with ❤️ by The LaunchBadge team SQLx is an async, pure Rust† SQL crate featuring compile-tim

launchbadge 7.6k Dec 31, 2022
A tool for automated migrations for PostgreSQL, SQLite and MySQL.

Models Models is an implementation for a SQL migration management tool. It supports PostgreSQL, MySQL, and SQLite. Quick Start install the CLI by runn

null 45 Nov 16, 2022
A highly scalable MySQL Proxy framework written in Rust

mysql-proxy-rs An implementation of a MySQL proxy server built on top of tokio-core. Overview This crate provides a MySQL proxy server that you can ex

AgilData 175 Dec 19, 2022
Asyncronous Rust Mysql driver based on Tokio.

mysql-async Tokio based asynchronous MySql client library for rust programming language. Installation Library hosted on crates.io. [dependencies] mysq

Anatoly I 292 Dec 30, 2022
Mysql client library implemented in rust.

mysql This crate offers: MySql database driver in pure rust; connection pool. Features: macOS, Windows and Linux support; TLS support via nativetls cr

Anatoly I 548 Dec 31, 2022
cogo rust coroutine database driver (Mysql,Postgres,Sqlite)

cdbc Coroutine Database driver Connectivity.based on cogo High concurrency,based on coroutine No Future<'q,Output=*>,No async fn, No .await , no Poll*

co-rs 10 Nov 13, 2022