From upesi
UpesiDB JavaScript API reference. Use when writing browser-side code that reads or writes data with UpesiDB.
How this skill is triggered — by the user, by Claude, or both
Slash command
/upesi:upesidb-js-apiThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Complete reference for the UpesiDB browser client. This library provides a schemaless document database for static websites hosted on Upesi.
Complete reference for the UpesiDB browser client. This library provides a schemaless document database for static websites hosted on Upesi.
<script src="/_db/db.js"></script>
No further configuration needed. The script exposes window.db with the correct API key embedded.
Prerequisite: Call upesi_db_key(app: "my-app") once to create the API key.
Collections are accessed as properties on db:
db.posts // → UpesiCollection for "posts"
db.users // → UpesiCollection for "users"
db.order_items // → UpesiCollection for "order_items"
Collections are created automatically on first write. No setup needed.
Collection naming rules: lowercase letters, numbers, underscores. Must start with a letter. Max 63 chars.
posts, user_scores, items22fast, my-posts, PostsDocuments are flat — your fields are at the top level:
{
id: 42,
title: "Hello", // ← your field
body: "World", // ← your field
created_at: "2025-01-15T...",
updated_at: "2025-01-15T..."
}
id, created_at, and updated_at are managed by the server.
All methods are async and return Promises.
Create a new document. Returns the created document with id.
const post = await db.posts.insert({ title: "Hello", body: "World" });
console.log(post.id); // 42
console.log(post.title); // "Hello"
Query documents. Returns paginated result.
// All documents
const result = await db.posts.find();
result.data.forEach(doc => console.log(doc.title));
// With filter
const result = await db.posts.find({ status: "published" });
// With filter, sorting, and pagination
const result = await db.posts.find(
{ status: "published" },
{ sort: { created_at: -1 }, limit: 10, offset: 0 }
);
Get a single document by ID.
const post = await db.posts.findOne(42);
console.log(post.title); // "Hello"
Merge fields into an existing document. Unmentioned fields are preserved.
await db.posts.update(42, { title: "New Title" });
// body is preserved, only title is updated
Replace all user fields. Unmentioned fields are removed.
await db.posts.replace(42, { title: "New" });
// body is gone, only title remains
Delete a document.
await db.posts.delete(42);
Count documents, optionally with a filter.
const { count } = await db.posts.count();
const { count } = await db.posts.count({ status: "draft" });
Used in find() and count():
| Operator | Example | Meaning |
|---|---|---|
| (exact) | { age: 25 } | Exact match |
$gt | { age: { $gt: 18 } } | Greater than |
$gte | { age: { $gte: 18 } } | Greater than or equal |
$lt | { age: { $lt: 65 } } | Less than |
$lte | { age: { $lte: 65 } } | Less than or equal |
$ne | { status: { $ne: "draft" } } | Not equal |
$in | { tag: { $in: ["a", "b"] } } | Value in array |
$or | { $or: [{ a: 1 }, { b: 2 }] } | Logical OR |
Pass sort in options to find():
{ sort: { created_at: -1 } } // descending (newest first)
{ sort: { created_at: 1 } } // ascending (oldest first)
Pass limit and offset in options to find():
{ limit: 10, offset: 20 }
Errors throw UpesiError with code, message, and status:
try {
await db.posts.insert({ title: "Hello" });
} catch (e) {
console.error(e.code, e.message);
// e.code: 'not_found' | 'unauthorized' | 'limit_exceeded' |
// 'payload_too_large' | 'server_error' | 'rate_limit'
}
| Resource | Limit |
|---|---|
| Document size | 1 MB |
| Documents per collection | 100,000 |
| Collections per app | 100 |
<script src="/_db/db.js"></script>
<script>
async function main() {
// Create
const post = await db.posts.insert({ title: "Hello", status: "published" });
// List published posts, newest first
const { data: posts, total } = await db.posts.find(
{ status: "published" },
{ sort: { created_at: -1 }, limit: 10 }
);
posts.forEach(p => console.log(p.title));
// Update
await db.posts.update(post.id, { title: "Updated Title" });
// Delete
await db.posts.delete(post.id);
}
main();
</script>
npx claudepluginhub oona-ai/upesi-dev-plugin --plugin upesiQueries, creates, updates, and deletes CloudBase document database data from browser apps using @cloudbase/js-sdk. Supports complex queries, pagination, aggregation, realtime subscriptions, and geolocation queries.
Performs CRUD operations on Firestore documents with typed data, collection hierarchy exploration, and structured querying.
Perform full CRUD operations on Wix CMS data collections: query, create, update, delete items with filtering, sorting, and aggregation.