0.2.2 • Published 11 months ago

prisma-extension-bark v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Bark

prisma-extension-bark is an implementation of the Materialized Path pattern that allows you to easily create and interact with tree structures in Prisma.

See the documentation to learn more.

Quick start

For more context please refer to our Getting Started guide.

1. Install dependencies

npm i @prisma/client prisma-extension-bark 
npm i -D prisma
npx prisma init

2. Implement the required field on your model

// prisma/schema.prisma
model node {
    // Extension's internal fields
    id       Int    @id @default(autoincrement())
    path     String @unique
    depth    Int
    numchild Int    @default(0)
    
	// Your fields go here...
    name     String

    @@index([path])
}

3. Create migrations

npx prisma migrate dev

4. Extend Prisma Client with Bark

// index.js
import { PrismaClient } from '@prisma/client'
import { withBark } from 'prisma-extension-bark'

const xprisma = new PrismaClient().$extends(withBark({ modelNames: ['node'] }))

const myNewRootNode = await xprisma.node.createRoot({ data: { name: 'My new root' } })
// { id: 1, path: '0001', depth: 1, numchild: 0, name: 'My new root' }
1.0.0-next.0

11 months ago

1.0.0-next.1

11 months ago

1.0.0-next.2

11 months ago

0.2.2

1 year ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.1-next.3

2 years ago

0.0.1-next.2

2 years ago

0.0.1-next.1

2 years ago

0.0.1-next.0

2 years ago