RepoDB is a performance-first, multi-tenant SQLite-as-a-Service designed to scale. By abstracting the complexities of database management into a high-speed HTTP API, we allow developers to deploy production-ready databases in seconds.
Unlike traditional databases that require persistent TCP connections (which can exhaust resources on Edge runtimes like Vercel or Cloudflare), RepoDB uses a stateless REST architecture. Every query is an encrypted HTTP request, making it the perfect choice for serverless environments.
Get your first database running in under 60 seconds.
Log in to the Dashboard and
generate an API Token. Note down your unique Host URL (usually
https://repodb.ogensync.com).
npm install @suman-malik-repo/repodb-client
import Repodb from '@suman-malik-repo/repodb-client';
const db = new Repodb({
host: 'https://repodb.ogensync.com',
token: 'your_api_token_here'
});
const result = await db.execute("SELECT 'Hello World' as greeting");
console.log(result.rows[0].greeting);
The RepoDB client is a lightweight, zero-dependency wrapper around the Fetch API. It is designed to run in Node.js, Browsers, and Edge environments.
npm i @suman-malik-repo/repodb-client
yarn add @suman-malik-repo/repodb-client
pnpm add @suman-malik-repo/repodb-client
RepoDB requires explicit configuration to route your requests to the
correct cluster. The host parameter is mandatory.
| Option | Type | Requirement | Description |
|---|---|---|---|
host |
URL String | Required | The base URL of your RepoDB instance. (e.g.,
https://repodb.ogensync.com)
|
token |
JWT String | Required | Your organization or project API token. |
dialect |
'sqlite' | 'mysql' | Optional | Defaults to sqlite. Determines syntax interpretation. |
We provide full support for both modern ES Modules and legacy CommonJS environments.
const Repodb = require('@suman-malik-repo/repodb-client');
const db = new Repodb({ host: '...', token: '...' });
(async () => {
const res = await db.execute("SELECT datetime('now')");
console.log(res.rows);
})();
import Repodb from '@suman-malik-repo/repodb-client';
const db = new Repodb({ host: '...', token: '...', dialect: 'mysql' });
const { rows } = await db.execute("SHOW TABLES");
The constructor accepts a configuration object. Using environment variables is strongly recommended.
const db = new Repodb({
host: process.env.REPODB_HOST,
token: process.env.REPODB_TOKEN,
dialect: 'mysql', // optional
timeout: 10000 // internal fetch timeout
});
The core of the SDK. It handles parameterized queries and returns structured data.
await db.execute("SELECT * FROM users WHERE email = ?", [userEmail]);
const sql = `
INSERT INTO logs (action) VALUES ('init');
UPDATE session SET last_active = datetime('now');
`;
await db.execute(sql);
{
"rows": [ { "id": 1, "name": "Suman" } ],
"columns": ["id", "name"],
"meta": {
"duration": 25,
"changes": 0,
"lastInsertRowid": null
}
}
json_extract.
ON CONFLICT syntax.Translation Layer: RepoDB translates MySQL-style identifiers (backticks) and specific date functions to their SQLite equivalents on the fly.
| Feature | MySQL | SQLite |
|---|---|---|
| Quoting | `backtick` | "double quote" |
| Auto Inc | INT AUTO_INCREMENT | INTEGER PK AUTOINC |
| Date Now | NOW() | datetime('now') |
| Concat | CONCAT(a, b) | a || b |
RepoDB supports standard SQL transactions to ensure data integrity.
await db.execute("BEGIN TRANSACTION;");
try {
await db.execute("UPDATE accounts SET bal = bal - 10 WHERE id = 1");
await db.execute("UPDATE accounts SET bal = bal + 10 WHERE id = 2");
await db.execute("COMMIT;");
} catch (e) {
await db.execute("ROLLBACK;");
}
The client throws an error if the status code is not 2xx. Catch these errors to handle database constraints or network issues.
try {
await db.execute("INSERT INTO users (id) VALUES (1)");
} catch (error) {
console.error("Query failed:", error.message);
// Possible errors: "UNIQUE constraint failed", "SQLITE_ERROR", etc.
}
Index every column used in WHERE and JOIN. It's the #1 speed boost for SQLite.
Use multi-statement strings to combine related operations into a single network call.