Why Fauna?
Fauna is a serverless, globally distributed document-relational database. It combines the flexibility of documents with relational features like joins, indexes, and ACID transactions — all via an API. No servers to manage, no connection pools.
Free tier: 100K read ops, 50K write ops, 5GB storage per day.
Getting Started
1. Create Free Account
Sign up at fauna.com — no credit card required.
2. Install the Shell
npm install -g fauna-shell
fauna cloud-login
fauna create-database my-app
3. Define Schema (FQL v10)
// Create collections
Collection.create({ name: "users" })
Collection.create({ name: "orders" })
// Define fields with types
users.definition.replace({
fields: {
name: { signature: "String" },
email: { signature: "String", unique: true },
plan: { signature: "String" }
}
})
JavaScript SDK
import { Client, fql } from "fauna";
const client = new Client({ secret: "YOUR_FAUNA_SECRET" });
// Create a user
const user = await client.query(fql`
users.create({
name: "Alice",
email: "alice@example.com",
plan: "pro"
})
`);
console.log(user.data);
// Query with filters
const proUsers = await client.query(fql`
users.where(.plan == "pro").order(desc(.ts))
`);
for (const u of proUsers.data.data) {
console.log(`${u.name} (${u.email})`);
}
// Transaction (ACID — globally consistent)
const result = await client.query(fql`
let buyer = users.byId("123")
let seller = users.byId("456")
let order = orders.create({
buyer: buyer,
seller: seller,
total: 99.99,
status: "paid"
})
order
`);
Python Client
from fauna import fql
from fauna.client import Client
client = Client(secret="YOUR_FAUNA_SECRET")
# Create documents
result = client.query(fql("""
users.create({
name: "Bob",
email: "bob@example.com",
plan: "free"
})
"""))
print(f"Created: {result.data}")
# Aggregation
result = client.query(fql("""
let plans = users.all().map(u => u.plan)
{
total: users.all().count(),
pro: users.where(.plan == "pro").count(),
free: users.where(.plan == "free").count()
}
"""))
print(result.data)
REST API (HTTP)
curl -X POST https://db.fauna.com/query/1 \
-H 'Authorization: Bearer YOUR_SECRET' \
-H 'Content-Type: application/json' \
-d '{"query": "users.all().take(10)"}'
Fauna vs Alternatives
| Feature | Fauna | MongoDB Atlas | DynamoDB |
|---|---|---|---|
| Global distribution | Built-in | Manual | Per-region |
| ACID transactions | Yes, global | Yes, local | Limited |
| Relational joins | Yes | Lookup only | No |
| Serverless | True | Semi | True |
| Free tier | 100K reads/day | 512 MB | 25 WCU/RCU |
Need to populate Fauna with web data? I build production-ready scrapers. Check out my Apify actors or email spinov001@gmail.com for custom data pipelines.
Building with Fauna? Share your architecture below!
Top comments (0)