Appearance
Collections
DSCollection (writes)
Type-bound write operations. The type is set once when you get the collection, so you don't repeat it on every call.
typescript
const bookmarks = store.type<Bookmark>('bookmark');add(doc)
typescript
const [errors, hash] = await bookmarks.add({
uid,
url: 'https://example.com',
title: 'Example',
});addMany(docs)
typescript
const [errors, hashes] = await bookmarks.addMany([
{ uid, url: 'https://a.com', title: 'A' },
{ uid, url: 'https://b.com', title: 'B' },
]);edit(uid, filter, update)
typescript
const [errors, newHash] = await bookmarks.edit(uid, { hash }, {
$set: { title: 'Updated' }
});save(uid, hash, content)
typescript
const [errors, newHash] = await bookmarks.save(uid, hash, {
title: 'New Title',
url: 'https://example.com',
});Reads — query your database directly
Document-store renders documents into your database. Query them using your database's native tools:
typescript
// SurrealDB
const [bookmarks] = await db.query('SELECT doc FROM bookmark ORDER BY doc.updatedAt DESC');
// SQLite
const bookmarks = db.prepare('SELECT * FROM bookmark ORDER BY updatedAt DESC').all();
// MongoDB
const bookmarks = await mongoCollection.find({ uid }).sort({ updatedAt: -1 }).toArray();See Querying guide for details.