How to fix "createMany does not exists..." in prisma?

Viewed 985

I'm planning to create a seeder for my projects table. I'm using createMany to insert multiple data in just a query (see code below). But the problem is, it does not recognize createMany and throws and error after running a jest test.

Another thing that is confusing me, there was no typescript error in my code. And I can create also single data using create function.

I already been to prisma documentation, but I can't determine what was wrong in my code. Could someone help me figure it out. (comments would also help).

error TS2339: Property 'createMany' does not exist on type 'ProviderDelegate<RejectOnNotFound | RejectPerOperation | undefined>'.


schema.prisma

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "sqlite"
  url      = "file:./dev.db"
}

model Provider {
  id Int @id @default(autoincrement())
  user_id Int
  name String
  space_key String
  api_key String
  projects Project[]
  created_at DateTime @default(now())
  updated_at DateTime @updatedAt
  @@unique([user_id, api_key])
}

my usage

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

...

await prisma.provider.createMany({
  data: [
    {
      user_id: 1,
      name: 'Nicole Sal',
      space_key: 'nic_spa',
      api_key: 'nic_api',
      created_at: new Date(),
      updated_at: new Date()
    },
    // ... more data here (same at above)
  ]
})
1 Answers
Related