Skip to main content

Key Differences

PrismaIlanaORM
SchemaSeparate .prisma file — extra language to learnPlain JavaScript class properties
ModelsAuto-generated client — regenerate after every changeWrite once, full control
Migrationsprisma migrate dev — codegen can drift from actual DBnpx ilana migrate — code-first, predictable
RelationsDefined in schema file, away from your codeMethods on the class, right where you use them
Type safetyGenerated types (requires build step)Auto-generated from migrations via npx ilana types — no build step
Soft deletesManual middleware or extensionOne line: static softDeletes = true
Type generation: IlanaORM generates TypeScript types automatically from your migration files. Run npx ilana types (or just run npx ilana migrate — it runs automatically). Types are written to types/ with a full Attributes interface and class declaration per model. No build step, no schema file, no regeneration loop.

Model Definition

model User {
  id        Int      @id @default(autoincrement())
  name      String
  email     String   @unique
  role      Role     @default(USER)
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  posts     Post[]
}

enum Role {
  USER
  ADMIN
}

Querying

// Find all
await prisma.user.findMany();

// Find unique
await prisma.user.findUnique({ where: { id: 1 } });

// Find with filter
await prisma.user.findMany({
  where: { role: 'ADMIN' }
});

// Find with relation
await prisma.user.findUnique({
  where: { id: 1 },
  include: { posts: true }
});

Creating Records

const user = await prisma.user.create({
  data: { name: 'Alice', email: 'alice@example.com' }
});

Updating Records

// Update one
await prisma.user.update({
  where: { id: 1 },
  data: { name: 'Alicia' }
});

// Update many
await prisma.user.updateMany({
  where: { role: 'USER' },
  data: { role: 'MEMBER' }
});

Deleting Records

await prisma.user.delete({ where: { id: 1 } });

// Soft delete (manual middleware in Prisma)
await prisma.user.update({
  where: { id: 1 },
  data: { deletedAt: new Date() }
});

Relations

// One-to-many
await prisma.user.findUnique({
  where: { id: 1 },
  include: {
    posts: {
      where: { published: true },
      orderBy: { createdAt: 'desc' },
    }
  }
});

// Many-to-many
await prisma.post.findUnique({
  where: { id: 1 },
  include: { tags: true }
});

Transactions

await prisma.$transaction(async (tx) => {
  const user = await tx.user.create({ data: { name: 'Alice' } });
  await tx.post.create({ data: { title: 'Hello', userId: user.id } });
});

Pagination

const [users, total] = await prisma.$transaction([
  prisma.user.findMany({ skip: (page - 1) * 10, take: 10 }),
  prisma.user.count(),
]);

Migration Path

  1. Convert your schema.prisma models into IlanaORM Model classes
  2. Write migrations using IlanaORM’s migration runner
  3. Replace prisma.model.findMany({ where, include, orderBy }) with the chainable QueryBuilder API
  4. Replace prisma.$transaction with DB.transaction
  5. Add static softDeletes = true instead of manual deletedAt middleware