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
Errors
Common errors & fixes
Cannot find module 'berry-orm' or its corresponding type declarations.
Missing npm install or incorrect import path.
fixRun '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.
fixEnsure 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.
fixCheck documentation: BerryOrm instance has property 'em' (entity manager). Ensure correct import.
Audit
Dependencies
No dependency data recorded yet.