Registry / database / berry-orm

berry-orm

JSON →
library0.3.0jsnpmunverified

Berry ORM is a lightweight, TypeScript-first ORM focused on relation mapping with strong type inference. Current stable version is 0.3.0. It is a generic object-relation mapper that works with any data sources, emphasizing type safety via decorators and generics. Requires TypeScript 4.1–4.5. Differentiates from other ORMs by its focus on frontend usage, minimal runtime, and deep TypeScript integration, but is experimental and not widely adopted.

npm install berry-orm
INSTALL
IMPORT
SIG · BERRY-ORM
B
berry-orm
databasejavascriptv0.3.0
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.

BerryOrm
import { BerryOrm } from 'berry-orm'
const BerryOrm = require('berry-orm')
Package is ESM-only; CommonJS require will fail.
Entity
import { Entity } from 'berry-orm'
import { Entity } from 'berry-orm/decorators'
All decorators are re-exported from main entry.
BaseEntity
import { BaseEntity } from 'berry-orm'
import { BaseEntity } from 'berry-orm/entity'
BaseEntity is from main package; no subpath export.
Field
import { Field } from 'berry-orm'
Import from 'berry-orm' — not from a separate decorator module.
Primary
import { Primary } from 'berry-orm'
Import from 'berry-orm' — not from a separate decorator module.
Relation
import { Relation } from 'berry-orm'
Import from 'berry-orm' — not from a separate decorator module.
Collection
import { Collection } from 'berry-orm'
Import from 'berry-orm' — not from a separate decorator module.

Defines Book and Author entities with relations, resolves a book with nested author, and accesses the author name.

import { BerryOrm, Entity, Primary, Field, BaseEntity, Relation, Collection } from 'berry-orm'; @Entity() class Book extends BaseEntity<Book, 'id'> { @Primary() @Field() id!: number; @Field() name!: string; @Relation({ target: () => Author, inverse: 'books' }) @Field() author!: Author; } @Entity() class Author extends BaseEntity<Author, 'id'> { @Primary() @Field() id!: number; @Field() name!: string; @Relation({ target: () => Book, inverse: 'author', multi: true }) @Field() books!: Collection<Book>; } const orm = new BerryOrm({ entities: [Book, Author] }); const book = orm.em.resolve(Book, { id: 1, name: '1000 Ways to Code', author: { id: 1, name: 'Char2s' }, }); console.log(book.author.name); // Char2s
Debug
Known issues
deprecatedTypeScript versions older than 4.1 or newer than 4.5 are not supported.
fix
Use TypeScript 4.1–4.5.
affects: >=0.3.0
gotchaAll entity classes must extend BaseEntity with generic parameters.
fix
Ensure entity classes extend BaseEntity<EntityClass, PrimaryFieldName>.
affects: >=0.0.0
gotchaDecorators like @Field and @Primary must be used on class properties; omitting them may cause runtime errors.
fix
Always apply @Field on all persistent fields and @Primary on primary key.
affects: >=0.0.0
gotchaThe package is ESM-only; require() will not work.
fix
Use import syntax or enable ESM in your project.
affects: >=0.3.0
breakingBreaking changes may occur in future versions as the library is still experimental (v0.x).
fix
Pin to a specific version and test updates carefully.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'berry-orm' or its corresponding type declarations.
Missing npm install or incorrect import path.
fix
Run 'npm install berry-orm' and ensure import is 'import { ... } from 'berry-orm''.
TypeError: Class extends value undefined is not a constructor or null
Forget to call @Entity decorator or BaseEntity is not imported correctly.
fix
Ensure entity class has @Entity() decorator and extends BaseEntity<...>.
Property 'em' does not exist on type 'BerryOrm'
Using an older version where API might differ or typo.
fix
Check documentation: BerryOrm instance has property 'em' (entity manager). Ensure correct import.
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
berry-orm — npm install berry-orm · libregistry