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

Overview

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 provides CRUD operations for a MongoDB collection!!

It is meant to be optimized for:

⚡️ Execution Speed

Written in Rust with most optimized compiler settings and zero "virtual machine bloat" that exists with languages such as python, node, or go.

💵 Cost and Scalability

This project packages the Rust server as AWS Lambda functions where you pay for only the milliseconds or server time when your code is executing. As opposed to other architectures that involve running a server 24/7, serverless functions do not incur a cost when the system is not in use, and there is no more headache of configuring load balancing correctly.

📊 Large Amounts of Data

  • Rather than a "get all" method that, this project provides a "get single" and "get paginated list" which uses cursor pagination

  • Includes a "move data to lake" to lake function which offloads old documents from the mongo "application database" over to a mongo "data lake" for long-term storage and analytics purposes.

Usage

This is a Rust project. Please first install cargo and serverless.

Running Tests:

cargo test

Running Locally (Note - not working for me...)

sls invoke local -f function_name

Deploying:

sls deploy

Note: You will need to first configure your aws cli before deploying:

aws configure

Customize For Your Data

Modify constants defined in .env to your liking.

You may also want to update your resource name.

This must be done manually at the current time...

Do a project find-and-replace for these things:

  • cat -> my_new_resource_name
  • Cat -> MyNewResourceName
  • CAT -> MY_NEW_RESOURCE_NAME

You can also add / remove fields on the Cat struct defined in: ./src/cat/cat.model.rs

REST Naming Conventions

We usually recommend using the plural form of the resource for which you are building this CRUD API.

For example, if each document in your collection represents a "cat", then the url endpoint should be "cats".

CREATE - Inserting a New Cat

POST to: https://your_url/cats with cat details

READ - Getting An Individual Cat

GET: https://your_url/cats/123123123 where "123123123" is the document _id for the cat object to get.

READ - Getting Cats

GET: https://your_url/cats/123123123 where "123123123" is the document _id for the cursor document. Returns up to 10 cats after the cursor doc.

By default these get the full cat document. You can optionally pass a body with these requests which is used in the mongo "find" call the projection object, allowing you to call for a subset of the cat document (by specifying either the fields you want included or excluded in the data to get).

UPDATE - Updating A Cat

POST: https://your_url/cats/123123123 where "123123123" is the document _id for the document to update. Takes an object of fields to update and leaves existing fields on the document.

DELETE - Deleting A Cat

DELETE: https://your_url/cats/123123123 where "123123123" is the document _id for the document to delete.

LAKE - Moving Old Cats To Data Lake

POST: https://your_url/cats/move-stale Copies docs older than X days (default 30) to mongo data lake and deletes them from the db collection.

Unit Testing

This project has 100% code coverage and great assertions!

It uses a mock mongo server so that you can run the tests without calling out to an external database and without having to directly mock the functions in the external mongo crate.

E2e Testing

This project also has some end-to-end tests that ping each endpoint and fail if responses are not fast enough.

Uses the [artillery] project and defines e2e tests in yaml.

Benchmarks

// TODO - get some real data for these functions!!

Contributing

Feel free to open issues / PRs if you have ideas on how to improve this project

You might also like...
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

Yet another CRUD. This time in Rust.

crust ____ ____ _ ____ _____ / _\/ __\/ \ /\/ ___\/__ __\ | / | \/|| | ||| \ / \ | \__| /| \_/|\___ | | | \____/\_/\_\\___

Scalable and fast data store optimised for time series data such as financial data, events, metrics for real time analysis

OnTimeDB Scalable and fast data store optimised for time series data such as financial data, events, metrics for real time analysis OnTimeDB is a time

High performance and distributed KV store w/ REST API. 🦀
High performance and distributed KV store w/ REST API. 🦀

About Lucid KV High performance and distributed KV store w/ REST API. 🦀 Introduction Lucid is an high performance, secure and distributed key-value s

A Rust-based comment server using SQLite and an intuitive REST API.

soudan A Rust-based comment server using SQLite and an intuitive REST API. Soudan is built with simplicity and static sites in mind. CLI usage See sou

A Rust client for the ElasticSearch REST API

rs-es Introduction An ElasticSearch client for Rust via the REST API. Targetting ElasticSearch 2.0 and higher. Other clients For later versions of Ela

An Elasticsearch REST API client for Rust

elastic elastic is an efficient, modular API client for Elasticsearch written in Rust. The API is targeting the Elastic Stack 7.x. elastic provides st

SubZero - a standalone web server that turns your database directly into a REST/GraphQL api

What is this? This is a demo repository for the new subzero codebase implemented in Rust. subZero is a standalone web server that turns your database

🦀 REST API client implementation for freee, auto-generated from OpenAPI specification.

freee-rs REST API client implementation for freee, auto-generated from OpenAPI specification. Getting Started Add to your Cargo.toml as follows: [depe

Owner
Evaluates2
Evaluates2
RedisLess is a fast, lightweight, embedded and scalable in-memory Key/Value store library compatible with the Redis API.

RedisLess is a fast, lightweight, embedded and scalable in-memory Key/Value store library compatible with the Redis API.

Qovery 145 Nov 23, 2022
Blazingly fast data generation & seeding for MongoDB

Planter Blazingly fast and simple data generation & seeding for MongoDB Installation Use the package manager cargo to install planter. Add the followi

Valencian Digital 4 Jan 12, 2022
CRUD example with Rocket, Toql and MySQL

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

Artos 7 Jan 5, 2022
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
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
The official MongoDB Rust Driver

MongoDB Rust Driver This repository contains the officially supported MongoDB Rust driver, a client side library that can be used to interact with Mon

mongodb 1.1k Dec 30, 2022
This is superseded by the official MongoDB Rust Driver

This Repository is NOT a supported MongoDB product MongoDB Rust Driver Prototype NOTE: This driver is superseded by the official MongoDB Rust driver,

MongoDB, Inc. Labs 382 Nov 15, 2022
Teach your PostgreSQL database how to speak MongoDB Wire Protocol

“If it looks like MongoDB, swims like MongoDB, and quacks like MongoDB, then it probably is PostgreSQL.” ?? Discord | Online Demo | Intro Video | Quic

Felipe Coury 261 Jun 18, 2023
Automatically publish MongoDB changes to Redis for Meteor.

changestream-to-redis Warning The project is currently in its alpha phase. There are no production loads using it yet nor any large-scale tests were c

Radosław Miernik 8 Jul 29, 2023
A user crud written in Rust, designed to connect to a MySQL database with full integration test coverage.

SQLX User CRUD Purpose This application demonstrates the how to implement a common design for CRUDs in, potentially, a system of microservices. The de

null 78 Nov 27, 2022