{"id":42677,"library":"eden-db","title":"Eden DB","description":"Eden DB is a Firebase-style PostgreSQL wrapper for Node.js and TypeScript that provides zero-config collections with auto-migration, transactions, and type-safe queries. Current version is 0.0.2, released as an early alpha. It differentiates from traditional ORMs like Sequelize or TypeORM by offering a simpler, document-like interface similar to Firestore, while using PostgreSQL as the backend. The library automatically creates tables on first use, supports raw SQL queries, and includes migration support. Note: version 0.0.2 is pre-stable and may have breaking changes.","status":"active","version":"0.0.2","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","eden","db","postgres","database","orm","typescript"],"install":[{"cmd":"npm install eden-db","lang":"bash","label":"npm"},{"cmd":"yarn add eden-db","lang":"bash","label":"yarn"},{"cmd":"pnpm add eden-db","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"pg is a peer dependency used for PostgreSQL connection and query execution.","package":"pg","optional":false}],"imports":[{"note":"The package uses named exports; default import is not available. Also, using require() with destructuring may cause issues in ESM contexts.","wrong":"const eden = require('eden-db')","symbol":"db","correct":"import { db } from 'eden-db'"},{"note":"runMigrations is a named export, not default. Also ensure you have a valid pool instance passed as first argument.","wrong":"import runMigrations from 'eden-db'","symbol":"runMigrations","correct":"import { runMigrations } from 'eden-db'"},{"note":"QueryOptions is a type (interface), so use 'import type' in TypeScript to avoid runtime errors. The package ships TypeScript types.","wrong":"import { QueryOptions } from 'eden-db'","symbol":"QueryOptions","correct":"import type { QueryOptions } from 'eden-db'"}],"quickstart":{"code":"import { db } from 'eden-db';\nimport 'dotenv/config';\n\nasync function main() {\n  // Connect (auto-creates tables on first use)\n  await db.connect({ url: process.env.DATABASE_URL ?? '' });\n\n  // Insert a user\n  const user = await db.collection('users').insert({\n    name: 'Alice',\n    email: 'alice@example.com',\n    role: 'admin',\n  });\n  console.log('Inserted:', user);\n\n  // Find all users\n  const users = await db.collection('users').find();\n  console.log('All users:', users);\n\n  // Find user by ID\n  const found = await db.collection('users').findById(user.id);\n  console.log('Found:', found);\n\n  // Query with filters\n  const admins = await db.collection('users').find({\n    where: { role: 'admin' },\n    orderBy: { field: 'createdAt', direction: 'desc' },\n    limit: 10,\n  });\n  console.log('Admins:', admins);\n\n  // Count\n  const count = await db.collection('users').count({ role: 'admin' });\n  console.log('Count:', count);\n\n  // Update\n  await db.collection('users').update(user.id, { name: 'Alice Smith' });\n\n  // Delete\n  await db.collection('users').delete(user.id);\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Demonstrates basic CRUD operations: connect, insert, find, findById, query with filters, count, update, and delete."},"warnings":[{"fix":"Review the generated schema in your database after first insert and consider using explicit migrations via runMigrations().","message":"Auto-migration creates tables on insert without schema validation, which may cause unexpected column types or conflicts with existing tables.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Ensure table names match your schema or use raw SQL for custom tables.","message":"The .collection() method returns a collection object that uses a table name inferred from the collection name (e.g., 'users' maps to 'users' table). If the table already exists with a different schema, insert may fail.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Always pass the client parameter to collection methods inside transactions: db.collection('users').insert(data, client)","message":"Transactions require passing a client object explicitly to each collection method inside the transaction callback; forgetting leads to operations running outside the transaction.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"None.","message":"No deprecated APIs known as version 0.0.2 is early stage.","severity":"deprecated","affected_versions":"<0.0.1"},{"fix":"For complex counts, use raw SQL via db.query().","message":"The .count() method accepts a where object but does not support advanced operators like $gt or $in; only exact equality.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Use ES module syntax or set \"type\": \"module\" in package.json.","message":"The package uses ESM modules. Using require() in CommonJS projects will fail unless using dynamic import().","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Pre-create tables via SQL or use runMigrations() once during startup to avoid repeated schema checks.","message":"Auto-migration runs on every insert, which may cause performance issues on high-traffic inserts.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"search_vec":"'0.0.2':35,85 'alpha':40 'auto':24 'auto-migr':23 'automat':69 'backend':66 'break':93 'chang':94 'collect':21 'config':20 'creat':70 'current':32 'databas':99 'db':2,4,97 'differenti':42 'document':55 'document-lik':54 'earli':39 'eden':1,3,96 'firebas':8 'firebase-styl':7 'firestor':60 'first':73 'includ':80 'interfac':57 'javascript':95 'librari':68 'like':46,56 'may':91 'migrat':25,81 'node.js':13 'note':83 'offer':51 'orm':45,100 'postgr':98 'postgresql':10,63 'pre':88 'pre-stabl':87 'provid':17 'queri':31,78 'raw':76 'releas':36 'safe':30 'sequel':47 'similar':58 'simpler':53 'sql':77 'stabl':89 'style':9 'support':75,82 'tabl':71 'tradit':44 'transact':26 'type':29 'type-saf':28 'typeorm':49 'typescript':15,101 'use':62,74 'version':33,84 'wrapper':11 'zero':19 'zero-config':18","created_at":"2026-06-05T16:56:07.603032+00:00","updated_at":"2026-06-05T16:56:07.603032+00:00","problems":[{"fix":"Run 'npm install eden-db pg' and ensure 'node_modules' is present. For TypeScript, ensure 'skipLibCheck' is false or add 'eden-db' to 'types' in tsconfig.json.","cause":"Module not installed or TypeScript can't find types.","error":"Cannot find module 'eden-db' or its corresponding type declarations."},{"fix":"Use named import: import { db } from 'eden-db'","cause":"Using default import instead of named import.","error":"Property 'connect' does not exist on type 'typeof import(\"eden-db\")'."},{"fix":"Ensure 'await db.connect()' is called before any collection operations. The table is created on first insert; if you need pre-creation, run a manual migration.","cause":"Auto-migration didn't run because insert was called before connect or table was not created.","error":"error: relation \"users\" does not exist"},{"fix":"Inside db.transaction callback, use db.collection('users').insert(data, client) where client is the argument of the callback.","cause":"Using transactional method without passing client parameter.","error":"client is not defined"},{"fix":"Set \"type\": \"module\" in package.json or use dynamic import: const { db } = await import('eden-db');","cause":"Package uses ESM, but project is CommonJS.","error":"Cannot use import statement outside a module"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"eden-db","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}