Backend & SDK

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:

OperatorExample
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" } }
RuleWho can readWho can write
publicAnyoneAnyone
authSigned-in app usersSigned-in app users
privateEach user sees only their own recordsOnly the record's owner
readonlyAnyoneOnly you, from the Data tab
submitOnly you and app adminsAnyone can send entries
appendAnyoneAnyone can add; each person changes or deletes only their own
membersSigned-in users with an active subscriptionSigned-in users with an active subscription
members-privateEach subscriber sees only their own recordsOnly the record's owner
teamYou and the users you make adminsYou and the users you make admins
directThe sender, the recipient and app adminsOnly 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.