Registry / database / prisma-entity-framework

prisma-entity-framework

JSON →
library2.1.0jsnpmunverified

TypeScript Entity Framework extending Prisma Client with Active Record pattern, declarative query builder, relation graph traversal, and batch operations. Current version 2.1.0 with monthly releases. Differentiators: full Active Record instance methods (create, update, delete on entity objects), fluent query DSL with LIKE/range/list filters, automatic upsert, graph path finding, pagination utilities, and performance metrics—filling gaps in Prisma Client without sacrificing type safety. Requires @prisma/client >=6.0.0 <7.0.0 and Node>=16.

npm install prisma-entity-framework
INSTALL
IMPORT
SIG · PRISMA-ENTITY-FRAM
P
prisma-entity-framework
databasejavascriptv2.1.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.

configurePrisma
import { configurePrisma } from 'prisma-entity-framework'
const configurePrisma = require('prisma-entity-framework').configurePrisma
ESM-only; no longer supports CJS require pattern as of v2.
BaseEntity
import { BaseEntity } from 'prisma-entity-framework'
import BaseEntity from 'prisma-entity-framework/BaseEntity'
Named export, not default. Path sub-import not supported.
Property
import { Property } from 'prisma-entity-framework'
import { Property } from '@prisma/client'
Must be from prisma-entity-framework, not @prisma/client. Decorator for mapping entity properties.

Demonstrates configuring Prisma, creating an Active Record entity, and using the query builder with search and pagination.

import { PrismaClient } from '@prisma/client'; import { configurePrisma, BaseEntity, Property } from 'prisma-entity-framework'; import { User as PrismaUser } from '@prisma/client'; const prisma = new PrismaClient(); configurePrisma(prisma); class User extends BaseEntity<PrismaUser> { static readonly model = prisma.user; @Property() declare id: number; @Property() declare name: string; @Property() declare email: string; } async function main() { const user = new User({ name: 'Alice', email: 'alice@example.com' }); await user.create(); console.log('Created user:', user.id); const results = await User.findByFilter({ search: { stringSearch: [{ keys: ['email'], value: '@example.com', mode: 'LIKE' }] }, pagination: { page: 1, pageSize: 10 } }); console.log('Users:', results.data); } main().catch(console.error);
Debug
Known issues
breakingv2.0.0 dropped CJS support; all imports must use ESM syntax.
fix
Switch from require() to import statements. Update tsconfig to use ESM module.
affects: >=2.0.0
breakingv2.0.0 renamed 'searchFilters' to 'search' and 'paginationOptions' to 'pagination' in findByFilter.
fix
Replace { searchFilters: {...} } with { search: {...} } and { paginationOptions: {...} } with { pagination: {...} }.
affects: >=2.0.0
deprecatedThe 'onlyOne' option in findByFilter is deprecated and will be removed in v3. Use 'first()' or 'findFirst()' instead.
fix
Use User.findFirst() or limit query to one result via pagination.
affects: >=2.1.0
gotchaProperty decorator must be used on all entity fields that map to Prisma model fields; omitting it causes runtime errors on create/update.
fix
Ensure every field that corresponds to a Prisma column has the @Property decorator.
affects: >=1.0.0
gotchaThe static 'model' property must be set to the Prisma client delegate (e.g., prisma.user); setting it incorrectly causes method failures.
fix
Assign static readonly model = prisma.<modelName> where <modelName> matches your Prisma schema model.
affects: >=1.0.0
breakingv2.0.0 requires @prisma/client >=6.0.0; older versions cause peer dependency errors.
fix
Upgrade @prisma/client to version 6.0.0 or later.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'prisma-entity-framework'
Package not installed or incorrect import path.
fix
Run: npm install prisma-entity-framework@latest
TypeError: Class extends value undefined is not a constructor or null
BaseEntity import failed, likely due to mixing CJS/ESM.
fix
Use ESM imports: import { BaseEntity } from 'prisma-entity-framework' (not require).
PrismaClientValidationError: Invalid 'searchFilters' option
Using v1.x option name in v2.0+.
fix
Replace searchFilters with search and paginationOptions with pagination.
Uncaught TypeError: Cannot read properties of undefined (reading 'create')
static model property not set or set to undefined.
fix
Ensure static readonly model = prisma.<modelName> is correctly assigned.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
@prisma/clientrequiredPeer dependency; core runtime requirement for database operations
Agent activity
4 hits · last 30 days
node
4
Resources
prisma-entity-framework — npm install prisma-entity-framework · libregistry