Skip to content
On this page

Create

See prisma reference

Create a single record

The following query creates a single user with two fields:

js
const user = await app.service('User').create({
   data: {
      email: 'elsa@prisma.io',
      name: 'Elsa Prisma',
   },
})

Create multiple records

The following createMany query creates multiple users and skips any duplicates (email must be unique):

js
const createMany = await app.service('User').createMany({
  data: [
    { name: 'Bob', email: 'bob@prisma.io' },
    { name: 'Bobo', email: 'bob@prisma.io' }, // Duplicate unique key!
    { name: 'Yewande', email: 'yewande@prisma.io' },
    { name: 'Angelique', email: 'angelique@prisma.io' },
  ],
  skipDuplicates: true, // Skip 'Bobo'
})