drizzle-macros 0.1.5

A type-safe SQL query builder for Rust
Documentation

Drizzle RS Procedural Macros

This crate provides the procedural macros for Drizzle RS, a type-safe SQL query builder for Rust.

Core Macros

SQLite

  • [SQLiteTable] - Define SQLite table schemas with type safety
  • [SQLiteView] - Define SQLite view schemas with type safety
  • [SQLiteEnum] - Define enums that can be stored in SQLite
  • [SQLiteIndex] - Define indexes on SQLite tables
  • [SQLiteSchema] - Derive macro to group tables and indexes into a schema

PostgreSQL

  • [PostgresTable] - Define PostgreSQL table schemas with type safety
  • [PostgresView] - Define PostgreSQL view schemas with type safety
  • [PostgresEnum] - Define enums for PostgreSQL (text, integer, or native ENUM)
  • [PostgresIndex] - Define indexes on PostgreSQL tables
  • [PostgresSchema] - Derive macro to group tables and indexes into a schema

Shared

  • [SQLiteFromRow] - Derive automatic row-to-struct conversion
  • [sql!] - Build SQL queries with embedded expressions

Example Usage

use drizzle::sqlite::prelude::*;

#[SQLiteTable(name = "users")]
struct Users {
    #[integer(primary, autoincrement)]
    id: i32,
    #[text]
    name: String,
    #[text]
    email: Option<String>,
}

#[derive(SQLiteSchema)]
struct Schema {
    users: Users,
}

For more detailed documentation, see the individual macro documentation below.