| 3 | const prisma = new PrismaClient() |
| 4 | |
| 5 | async function main() { |
| 6 | const jane = await prisma.user.upsert({ |
| 7 | where: { email: 'jane@prisma.io' }, |
| 8 | update: {}, |
| 9 | create: { |
| 10 | email: 'jane@prisma.io', |
| 11 | name: 'Jane', |
| 12 | posts: { |
| 13 | create: [ |
| 14 | { |
| 15 | title: |
| 16 | 'Comparing Database Types: How Database Types Evolved to Meet Different Needs', |
| 17 | content: |
| 18 | 'https://www.prisma.io/blog/comparison-of-database-models-1iz9u29nwn37/', |
| 19 | published: true, |
| 20 | }, |
| 21 | { |
| 22 | title: 'Analysing Sleep Patterns: The Quantified Self', |
| 23 | content: 'https://quantifiedself.com/get-started/', |
| 24 | published: true, |
| 25 | }, |
| 26 | ] |
| 27 | } |
| 28 | } |
| 29 | }) |
| 30 | |
| 31 | const bob = await prisma.user.upsert({ |
| 32 | where: { email: 'bob@prisma.io' }, |
| 33 | update: {}, |
| 34 | create: { |
| 35 | email: 'bob@prisma.io', |
| 36 | name: 'Bob', |
| 37 | posts: { |
| 38 | create: [ |
| 39 | { |
| 40 | title: |
| 41 | 'Deploying Prisma ORM to Traditional servers', |
| 42 | content: |
| 43 | 'https://www.prisma.io/docs/orm/prisma-client/deployment/traditional', |
| 44 | published: true, |
| 45 | }, |
| 46 | ] |
| 47 | } |
| 48 | } |
| 49 | }) |
| 50 | |
| 51 | console.log({ jane, bob }) |
| 52 | } |
| 53 | |
| 54 | main() |
| 55 | .then(async () => { |