Skip to content

Commit 0d9a980

Browse files
committed
03/02: move problem instructions to db-utils.ts
1 parent 23ac4ec commit 0d9a980

File tree

2 files changed

+32
-34
lines changed

2 files changed

+32
-34
lines changed

exercises/03.guides/02.problem.test-data/tests/db-utils.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,35 @@ export async function getUserImages() {
9898

9999
return userImages
100100
}
101+
102+
// 🐨 Declare and export an asynchronous function called `createNotes`.
103+
// 💰 export async function createNotes(args)
104+
//
105+
// 🐨 Annotate the `args` argument of the `createNotes` function to be
106+
// of the following type:
107+
// { ownerId: string, notes: Array<Omit<Prisma.NoteCreateManyInput, 'ownerId'>> }
108+
//
109+
// 🐨 In the body of the `createNotes` function, declare a variable called "notes".
110+
// As the value for this variable, assign the result of creating multiple
111+
// notes in the database.
112+
// 💰 const notes = await prisma.note.createManyAndReturn({})
113+
//
114+
// 🐨 In the argument to the `createManyAndReturn` method call, provide the "data"
115+
// key. As the value for the "data" key, iterate over `args.notes` and compose an
116+
// object of the following shape:
117+
// { ownerId: args.ownerId, ...note }
118+
// 💰 { data: args.notes.map((note) => ({ ... })) }
119+
//
120+
// 🐨 From the `createNotes` function, return an object that has a key "values".
121+
// Assign the `notes` variable as the value of the "values" key.
122+
// 💰 return { this: that }
123+
//
124+
// 🐨 In the object returned from the `createNotes` function, add an asynchronous
125+
// method that uses `Symbol.asyncDispose` as its dynamic key name. This will make
126+
// the `createNotes` utility disposable so you can delete the notes you've created
127+
// once this utility gets garbage-collected.
128+
// 💰 return { async[Symbol.asyncDispose]() {} }
129+
//
130+
// 🐨 In the asynchronous dispose callback, use the `prisma` client to delete
131+
// the notes where the owner id is `args.ownerId`.
132+
// 💰 await prisma.note.deleteMany({ where: {} })

exercises/03.guides/02.problem.test-data/tests/e2e/utils.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)