Registry / database / redbean-node

redbean-node

JSON →
library0.3.3jsnpmunverified

RedBeanNode v0.3.3 is a Node.js ORM inspired by RedBeanPHP, supporting MySQL/MariaDB and SQLite via Knex.js. It automatically creates tables and columns on the fly with zero configuration. Compatible with both JavaScript and TypeScript, it offers async/await-friendly CRUD operations. Not yet stable (early development), with infrequent releases. Unlike other ORMs, it eliminates schema definition, but this comes with risks for production use.

npm install redbean-node
INSTALL
IMPORT
SIG · REDBEAN-NODE
R
redbean-node
databasejavascriptv0.3.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

R
import { R } from 'redbean-node'
const R = require('redbean-node').R
Default export is not available; named import for ESM, destructured require for CJS.
R
const { R } = require('redbean-node')
const R = require('redbean-node')
CommonJS require must destructure 'R' from the module; direct require returns an object containing R.
redbean-node
import 'redbean-node'
require('redbean-node')
Importing the module without destructuring is possible for side effects, but typically you want R.

Demonstrates basic CRUD operations with automatic schema generation using SQLite in-memory.

const { R } = require('redbean-node'); async function main() { // SQLite in-memory database R.setup('sqlite::memory:'); // Create a bean (like a record) const book = R.dispense('book'); book.title = 'Sample Book'; book.author = 'John Doe'; // Store (insert or update) const id = await R.store(book); console.log('Stored book with id:', id); // Load by id const loaded = await R.load('book', id); console.log('Loaded:', loaded); // Delete await R.trash(loaded); // Close connection await R.close(); } main().catch(console.error);
Debug
Known issues
gotchaAutomatic table/column creation may generate unexpected schema changes. Do not use in production.
fix
Manually define schema in production or use a migration tool alongside RedBeanNode.
affects: >=0.0.0
gotchaDatabase connection is not automatically closed; must call R.close() or connection leaks may occur.
fix
Always call await R.close() after operations or use a try/finally block.
affects: >=0.0.0
deprecatedChangelog not maintained; breaking changes may go undocumented.
fix
Pin dependency and test thoroughly after updates. Check GitHub releases for any notes.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: R.setup is not a function
Incorrect import: using const R = require('redbean-node') instead of destructuring.
fix
Use const { R } = require('redbean-node') or import { R } from 'redbean-node'.
Error: SQLITE_ERROR: table "book" already exists
Automatic schema generation creates table on first store; an existing table conflicts.
fix
Drop the table manually or use R.setup() with a fresh database. Avoid mixing with pre-existing schemas.
TypeError: Cannot read properties of undefined (reading 'store')
R.store() called before setup() or after close().
fix
Ensure R.setup() is called before any operations and R.close() is only called after all operations.
Upgrade
Version history
0.3.3latest on npm
Audit
Dependencies
knexrequiredUnderlying query builder and SQL dialect support
mysql2optionalRequired for MySQL/MariaDB connections when using those databases
sqlite3optionalRequired for SQLite connections when using that database
Agent activity
4 hits · last 30 days
node
4
Resources
redbean-node — npm install redbean-node · libregistry