Entities & Persistence
Define data models and persist them automatically. Database without SQL.
Defining an Entity
Entities are like database tables, but simpler:
entity User {
name: text @required
email: text @email @unique
age: int @min(0)
bio: text? // optional
active: bool = true // default value
created: time = now
}
CRUDD Operations
FLIN uses CRUDD (not CRUD) — with two D's for delete and destroy:
| Operation | Description | Reversible? |
|---|---|---|
| Create | Insert new entity | — |
| Read | Query entities | — |
| Update | Modify entity fields | — |
| Delete | Soft delete (keeps history) | YES |
| Destroy | Hard delete (permanent) | NO |
// CREATE
user = User { name: "Juste", email: "[email protected]" }
save user
// READ
all = User.all // get all
one = User.find(123) // find by ID
active = User.where(active == true)
// UPDATE
user.name = "Juste Gnimavo"
save user
// DELETE (soft - keeps history, can restore)
delete user
restore user // bring it back!
// DESTROY (hard - permanent, GDPR compliant)
destroy user // gone forever
🐘 delete vs destroy
delete = FLIN remembers (soft delete, can restore)
destroy = FLIN forgets (hard delete, GDPR "right to be forgotten")
Validators
Built-in validation with 40+ validators:
entity Product {
name: text @required @minLength(3)
email: text @email
url: text @url
price: float @positive
stock: int @min(0) @max(10000)
sku: text @unique
}
Queries
Chain queries fluently:
// All active users over 18
User.where(age > 18).where(active == true)
// First 10 products under $50
Product.where(price < 50).limit(10)
// Count and first
count = User.count
first = User.first