Skip to content

Latest commit

 

History

History

diesel_crud_example

Sample CRUD API with Diesel and Actix Web

This project is a simple CRUD (Create, Read, Update, Delete) API implemented in Rust using the Actix Web framework and the Diesel ORM for interacting with a PostgreSQL database. It provides basic functionalities to manage samples data, including creating, retrieving, updating, and deleting sample records.

Prerequisites

Before getting started, make sure you have the following installed on your system:

Setup

  1. Install Diesel CLI:
cargo install diesel_cli --no-default-features --features "postgres"
  1. Set up the database:
  • Start the PostgreSQL database using Docker:
docker-compose up -d
  • Create the database schema:
diesel setup
  1. Set environment variables:
  • Create a .env file in the root directory and add the following content with your desired database credentials:
DATABASE_URL=postgres:https://your-db-user:your-db-password@localhost/sampledb

Building and Running the API

  • Build and run the API using Cargo:
cargo run

API endpoints

  • Refer the postman collection json in the root directory for all the details