database.do

raw JSON →
0.0.1 verified Sat Apr 25 auth: no javascript

An AI-native data access SDK currently at version 0.0.1 that abstracts common database operations across MongoDB, PostgreSQL, and SQLite. It leverages AI to automate schema inference, query generation, and data transformation. Designed for rapid prototyping and integration with AI agents, it prioritizes simplicity over raw performance, distinguishing itself from traditional ORMs by reducing boilerplate through natural language-like commands. Released weekly with breaking changes expected before 1.0.

error TypeError: Database is not a constructor
cause Incorrect import: using default import instead of named import
fix
Change to import { Database } from 'database.do'.
error Cannot find module 'database.do' or its corresponding type declarations.
cause TypeScript not configured for ESM resolution
fix
Set "moduleResolution": "node16" in tsconfig.json.
error UnhandledPromiseRejectionWarning: Error: No database type specified
cause Missing `type` field in Database constructor options
fix
Add type: 'postgres' | 'mongodb' | 'sqlite' to the options object.
error Error: Cannot find module 'pg'
cause PostgreSQL driver not installed
fix
Run npm install pg.
breaking v0.0.1 renames `createDatabase` to `Database` constructor; old import breaks
fix Use `new Database({...})` instead of `createDatabase({...})`.
breaking v0.0.1 removes `mongodb` driver from default installation; needs explicit opt-in
fix Install `mongodb` separately: `npm install mongodb`.
deprecated `query` method on `Database` instance is deprecated in favor of standalone `query` function
fix Use `import { query } from 'database.do'` and pass `db` as first argument.
gotcha Package is ESM-only; cannot `require()` in CommonJS projects
fix Switch to ESM or use dynamic `import('database.do')`.
gotcha TypeScript users must set `"moduleResolution": "node16"` or `"bundler"` for correct type inference
fix Update tsconfig.json: `"moduleResolution": "node16"`.
npm install database.do
yarn add database.do
pnpm add database.do

Connects to a PostgreSQL database using environment variable for URI, runs a parameterized query, and closes the connection.

import { Database } from 'database.do';

const db = new Database({
  type: 'postgres',
  connectionString: process.env.DATABASE_URL ?? 'postgresql://localhost:5432/mydb'
});

async function main() {
  await db.connect();
  const result = await db.query('SELECT * FROM users WHERE id = $1', [1]);
  console.log(result.rows);
  await db.close();
}

main().catch(console.error);