Database (b77.db)
Collections, queries, and per-user data.
b77.db is a schemaless document database. Collections are created automatically the first time you write to them.
Create
const task = await b77.db.create('tasks', { title: 'Ship v2', done: false, priority: 2 });
// → { id, title, done, priority, createdAt, updatedAt, ownerId }Read
const all = await b77.db.list('tasks');
const open = await b77.db.list('tasks', { where: { done: false }, sort: '-priority', limit: 50 });
const one = await b77.db.get('tasks', id); // null if missing
const count = await b77.db.count('tasks', { where: { done: true } });Filters
where matches fields exactly, and supports operators:
| Operator | Example |
|---|---|
| equals | { status: 'paid' } |
$ne | { status: { $ne: 'draft' } } |
$in | { status: { $in: ['sent', 'paid'] } } |
$gt / $gte / $lt / $lte | { total: { $gte: 100 } } |
$contains | { name: { $contains: 'ann' } } (case-insensitive) |
sort takes a field name, prefixed with - for descending (default -createdAt). limit is up to 500, offset paginates.
Update & delete
await b77.db.update('tasks', id, { done: true }); // shallow merge
await b77.db.replace('tasks', id, { title: 'New' }); // overwrite all fields
await b77.db.remove('tasks', id);Per-user data
Records created while a user is signed in get an ownerId. Query only the current user's records with mine: true:
const myNotes = await b77.db.list('notes', { mine: true });Records with an owner can only be updated or deleted by that owner.
Access rules
Every collection has an access rule, checked on the server. A collection without one gets a default based on its name: things people send in (orders, bookings, messages…) get submit, content you publish (products, menu, posts…) gets readonly, leaderboard and guestbook get append, and everything else is private. Change the rule per collection in the builder's Data tab, or let your app declare rules in a b77.config.json file:
{ "rules": { "notes": "private", "menu": "readonly", "orders": "auth" } }| Rule | Who can read | Who can write |
|---|---|---|
public | Anyone | Anyone |
auth | Signed-in app users | Signed-in app users |
private | Each user sees only their own records | Only the record's owner |
readonly | Anyone | Only you, from the Data tab |
submit | Only you and app admins | Anyone can send entries |
append | Anyone | Anyone can add; each person changes or deletes only their own |
members | Signed-in users with an active subscription | Signed-in users with an active subscription |
members-private | Each subscriber sees only their own records | Only the record's owner |
team | You and the users you make admins | You and the users you make admins |
direct | The sender, the recipient and app admins | Only the sender can change or delete a message |
Limits
Records up to 64 KB each (store files with b77.storage.upload instead). The number of records per app depends on your plan: 2,000 on Free, 20,000 on Starter, 50,000 on Plus, 100,000 on Pro and 200,000 on Elite.