Metadata-Version: 2.1
Name: cflaremodel
Version: 0.1.2
Summary: 
Author: Anthony Viriya
Author-email: 16130362+avltree9798@users.noreply.github.com
Requires-Python: >=3.10,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Description-Content-Type: text/markdown

# 🔥 CFlareModel

**CFlareModel** is a lightweight, async-first ORM for Python inspired by Laravel's Eloquent. Built for Cloudflare D1 and other serverless databases, it offers a fluent API, relationship management, and automatic schema introspection — all in a minimal package.

---

## ✨ Features

- ✅ Fluent, chainable query builder (`where()`, `with_()`, `limit()` etc.)
- ⚡ Async by default — built for modern Python 3.8+
- 🔁 Eager and lazy loading of relationships
- 📄 Schema introspection (`fillable`, `casts`, etc.)
- ☁️ D1-first, but pluggable with other SQL drivers

---

## 📦 Installation

```bash
pip install cflaremodel
```

---

## 🚀 Quickstart

```python
from cflaremodel import Model
from cflaremodel import D1Driver

# Example User model
class User(Model):
    table = "users"
    fillable = ["name", "email"]
    casts = {"created_at": "datetime"}

async def on_fetch(request, env):
    # Setup driver
    Model.set_driver(driver=D1Driver(env.DB))
    # Query
    users = await User.query().where("email", "like", "%@example.com").get()
```

---

## 🧱 Defining Relationships

```python
class Post(Model):
    table = "posts"

    async def user(self):
        return await self.belongs_to(User, "user_id")

class User(Model):
    table = "users"

    async def posts(self):
        return await self.has_many(Post, "user_id")
```

---

## 🧠 Schema Introspection

```python
User.introspect({
    "name": {"type": "str"},
    "email": {"type": "str"},
    "created_at": {"type": "datetime"},
    "hidden": ["password"]
})
```

---

## 📜 License

GNU GPLv3 © 2025 — avltree9798

