Developer Guide

Get started with FlinDB in 4 simple steps. No configuration required.

Quick Start

From zero to storing data in under a minute.

Install FLIN

FlinDB is included with the FLIN language. Install with a single command.

$ curl -fsSL https://flin.sh | bash

Define Your Entity

Create a data model with simple, declarative syntax. No SQL, no migrations.

app.flin
entity Todo {
    title: text
    completed: bool = false
    priority: int = 1
    created: time = now
}

Create and Save

Instantiate entities and save them. That's it. No boilerplate.

app.flin
// Create entity
todo = Todo { title: "Learn FlinDB" }

// Save to database
save todo

// Done! Auto-assigned: id, created_at, version

Query Your Data

Use the intuitive query builder to retrieve and filter data.

app.flin
// Get all todos
todos = Todo.all

// Filter
active = Todo.where(completed == false)

// Time travel
yesterday_state = todo@yesterday

Entity Definition

Define your data models with simple, declarative syntax.

Field Types

Type Description Example
textUTF-8 string"Hello"
int64-bit integer42
number64-bit float3.14
boolBooleantrue
timeUTC timestampnow
moneyCurrency1000 CFA
fileFile referenceupload
semantic textAI-searchable"desc"
entities.flin
// Basic entity
entity User {
    name: text
    email: text
    age: int
}

// With defaults
entity Todo {
    title: text
    done: bool = false
    created: time = now
}

// Optional fields
entity Profile {
    user: User
    bio: text?        // Optional
    avatar: file?     // Optional
}

CRUDD Operations

FlinDB uses CRUDD (Create, Read, Update, Delete, Destroy) with soft and hard delete options.

Operations

  • save entity Create or update an entity
  • Entity.find(id) Find entity by ID
  • Entity.all Get all entities
  • Entity.count Count entities
  • delete entity Soft delete (recoverable)
  • restore entity Restore soft-deleted entity
  • destroy entity Hard delete (permanent)
crud.flin
// CREATE
user = User { name: "Juste" }
save user

// READ
user = User.find(1)
users = User.all
count = User.count

// UPDATE
user.name = "Juste G."
save user  // New version created

// DELETE (soft - recoverable)
delete user
restore user  // Undo delete

// DESTROY (hard - permanent)
destroy user  // GDPR compliant

Querying

Chain query methods for powerful filtering, ordering, and pagination.

Query Methods

  • .where(condition) Filter by condition
  • .order(field, dir) Sort results (asc/desc)
  • .limit(n) Limit number of results
  • .offset(n) Skip first n results
  • .first(condition) Get first matching entity

Comparison Operators

== != > < >= <= && ||

queries.flin
// Simple filter
active = Todo.where(done == false)

// Multiple conditions
urgent = Todo
    .where(done == false)
    .where(priority > 3)

// Ordering
newest = Todo.all.order(created, desc)

// Chained query
results = Product
    .where(category == "tech")
    .where(price < 1000)
    .order(rating, desc)
    .limit(10)

// Pagination
page2 = User.all.limit(20).offset(20)

Temporal Queries

Query any entity at any point in time using the @ operator.

Temporal Syntax

  • entity@-1 Previous version
  • entity@-n n versions back
  • entity@"date" State on specific date
  • entity@yesterday State yesterday
  • entity.history() All versions

Keywords

now today yesterday tomorrow last_week last_month

temporal.flin
// Version-based
previous = user@-1
two_back = user@-2

// Date-based
state = user@"2024-01-15"
precise = user@"2024-01-15 14:30"

// Keywords
yesterday_state = user@yesterday
last_week_state = user@last_week

// Full history
versions = user.history()
count = user.history().length

// Compare versions
old = user@-1
if user.email != old.email {
    log("Email changed!")
}

Relationships

Define relationships between entities naturally.

Relationship Types

  • field: Entity One-to-one / Many-to-one
  • field: [Entity] One-to-many / Many-to-many
  • field: Entity? Optional relationship
relationships.flin
// One-to-many
entity User { name: text }
entity Post {
    title: text
    author: User
}

// Many-to-many
entity Tag { name: text }
entity Article {
    title: text
    tags: [Tag]
}

// Self-reference (tree)
entity Category {
    name: text
    parent: Category?
}

Ready to build?

$ curl -fsSL https://flin.sh | bash
View on GitHub See Comparison
Quick Links
Home Features Use Cases Compare
FLIN Ecosystem
flin.dev FLIN Docs FlinUI
GitHub Discord Twitter/X