BatmanAKC/zorm
ZORM is a Zig ORM library that simplifies database management with custom schema files. 🚀 You can easily integrate it into your projects and generate...
Welcome to Zorm, a powerful Object-Relational Mapping (ORM) library designed for the Zig programming language. Zorm simplifies database interactions by allowing developers to work with objects instead of raw SQL queries. With custom schema support, Zorm adapts to various database structures, making it flexible for different projects.
You can find the latest releases of Zorm here. Make sure to download and execute the appropriate files for your setup.
To get started with Zorm, follow these steps:
Clone the Repository:
git clone https://github.com/BatmanAKC/zorm.git
cd zorm
Build the Project:
zig build
Download the Latest Release: Visit the Releases section to download the latest version. Follow the instructions provided for installation.
Run the Example:
zig run example.zig
Using Zorm is straightforward. Here’s a quick example to illustrate how to connect to a database and perform basic operations.
const std = @import("std");
const zorm = @import("zorm");
pub fn main() !void {
const db = try zorm.connect("postgres://user:password@localhost:5432/mydb");
defer db.close();
// Your database operations here
}
try db.createTable("users", .{
.name = "VARCHAR(100)",
.email = "VARCHAR(100) UNIQUE",
});
try db.insert("users", .{
.name = "John Doe",
.email = "[email protected]",
});
const users = try db.query("SELECT * FROM users");
for (users) |user| {
std.debug.print("User: {}\n", .{user.name});
}
Zorm supports a variety of databases to suit your needs:
Each database has its own configuration requirements. Refer to the documentation for specifics on setting up each type.
Zorm’s custom schema support allows you to define your database structure according to your application’s needs. This flexibility means you can easily adapt to changes in your data model without extensive rewrites.
You can define a custom schema by creating a configuration file. Here’s an example:
const schema = .{
.users = .{
.name = "VARCHAR(100)",
.email = "VARCHAR(100) UNIQUE",
},
.posts = .{
.title = "VARCHAR(255)",
.content = "TEXT",
.user_id = "INTEGER",
},
};
This schema can then be used to create tables and enforce relationships between them.
We welcome contributions from the community! If you’d like to help improve Zorm, please follow these steps:
git checkout -b feature/your-feature-name
git commit -m "Add a feature"
git push origin feature/your-feature-name
We appreciate your contributions and feedback!
Zorm is licensed under the MIT License. See the LICENSE file for more information.
For questions, suggestions, or feedback, please reach out to the maintainer:
Feel free to connect with us and share your experiences using Zorm!
For more details, updates, and to explore the latest features, check the Releases section. Download the latest version and start building your applications with ease!