runebook · rune
runebook · rune
No capabilities requested.
manifest: sha256:b0674c1b6f1afaca979bb0c46bdf5b6d02d35ee87aaf4fbc9c928ee570f06c8c
rune add @rune/mongo@0.1.1rune add @rune/mongo
Provide a mongodb: or mongodb+srv: URL that names the database. The collection uses _id for record identity and a TTL index for expiration.
import { connect } from "@rune/mongo";
import { document } from "@rune/storage";
const db = await connect(process.env.DATABASE_URL!);
const visits = document(db.store, "visits", () => ({ total: 0 }));
await visits.update((value) => ({ total: value.total + 1 }));
// Call await db.close() when the connection is no longer needed.
Wrap an existing driver instance with mongoStore(collection).
Use db.store with Web Auth, or as a general-purpose record store.
Pass { name: "shared" } to connect to make the existing connection
reusable by other Runes. Storage configuration