Sorry for this, I have changed and found another way to do this. If anyone was curious on how i changed it (for future use if anyone gets stuck and gets the same results like this)
const prisma = new PrismaClient()
const { username, email, hashPassword } = await request.json();
let verified = crypto.randomBytes(32).toString('hex');
const userExist = await prisma.users.findFirst({ where: { OR: [{ username }, { email }] } })
if (userExist === null) {
await prisma.users.create({ data: { username, email, hashPassword, verified } })
return new NextResponse('Success!', { status: 201 })
} else {
return new NextResponse("Sorry, username and or email already exists!", { status: 500 })
}
GitHub
github.com › prisma › prisma › discussions › 16882
Using upsert · prisma/prisma · Discussion #16882
prisma.server.upsert({ where: { id: input.id ??
Author prisma
GitHub
github.com › prisma › prisma › discussions › 17974
Upsert into SQL table by multiple conditions failure in prisma python? #702 · prisma/prisma · Discussion #17974
My written code: record = db.table.upsert( where={'column1': 1, 'column2': 2, 'column3': 3} data={ 'create': { .... }, 'update': { .... }, }, ) And the error that I encounterd : prisma.errors.FieldNotFoundError: Failed to validate the query: `Expected exactly one field to be present, got 3.
Author prisma
Prisma.upsert() should support the value of null in where condition.
Bug description Prisma supports creating the nullable value for the table, but not support the null value in where condition of upsert() method. How to reproduce I wrote a simple reproducible examp... More on github.com
Difference between "update including create" and "create+update"?
Hi there, I've got a relatively simple problem and I was looking for the most elegant solution: The Model looks like this: model Zeitraum { id String @id @default(cuid()) abwesenheit Abwesenhei... More on github.com
database - How to use upsert with Prisma? - Stack Overflow
I'm trying to either update or create a record in my Profile table. I'm using Prisma to define the schema and it looks like this: model Profile { id String @id @default(cuid()) username ... More on stackoverflow.com
Distinguishing between update/insert in upsert
Hi there, I couldn't find a clear answer in the docs to the following question: Since the call return the updated/modified object, how does one know whether an upsert was an update or a create? Tha... More on github.com
GitHub
github.com › prisma › prisma › issues › 6359
Prisma.upsert() should support the value of null in where condition. · Issue #6359 · prisma/prisma
April 1, 2021 - bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.kind/bugA reported bug.A reported bug.topic: upsertnested upsertnested upsert ... Prisma supports creating the nullable value for the table, but not support the null value in where condition of upsert() method.
Author prisma
GitHub
github.com › prisma › prisma › discussions › 11966
Prisma `Upsert` works in `Update` but not `Create` · prisma/prisma · Discussion #11966
From the docs, it looks like I should be able to use upsert inside of a create. It's fine if this feature isn't built as I want to make sure I'm not doing anything wrong. An example of the working update is below. const createConversation = await prisma.conversations.update({ where: { id: 1, }, data: { body: 'This is a test', user: { upsert: { create: { email: 'bob@prisma.io', name: 'Bob the New User', }, update: { email: 'bob@prisma.io', name: 'Bob the existing user', }, }, }, }, })
Author prisma
GitHub
github.com › prisma › prisma › discussions › 3432
Distinguishing between update/insert in upsert · prisma/prisma · Discussion #3432
August 27, 2020 - One approach to resolve could be to compare the ID that you're passing to the where option in upsert with the ID that's returned by the upsert query: const maybeUserId = 42 const user = await prisma.user.upsert({ create: { name: "Nikolas", email: "burk@prisma.io" }, update: { name: "Nikolas", email: "burk@prisma.io", }, where: { id: maybeUserId } }) if (user.id === maybeUserId) { console.log(`An existing user was updated`) } else { console.log(`A new user was created`) }
Author prisma
GitHub
github.com › prisma › prisma › issues › 4134
Provide `upsertMany()`/`upsertFirst()` operation in the client API · Issue #4134 · prisma/prisma
November 2, 2020 - prisma / prisma Public · Notifications ... New issueCopy link · New issueCopy link · Open · Open · Provide upsertMany()/upsertFirst() operation in the client API#4134 · Copy link · Labels ·...
Author prisma
GitHub
github.com › RobertCraigie › prisma-client-py › discussions › 256
v0.5.0 · RobertCraigie/prisma-client-py · Discussion #256
You can now easily replace the Prisma CLI binary that Prisma Client Python makes use of by overriding the PRISMA_CLI_BINARY environment variable.
Author RobertCraigie
GitHub
github.com › prisma › prisma › issues › 11745
An ability to check if `upsert` was create or update. · Issue #11745 · prisma/prisma
February 10, 2022 - Problem The upsert method only returns the created or modified result but doesn't give any clue if it was create or update. I'd like to return an HTTP status code based on which operation w...
Author prisma
GitHub
github.com › prisma › prisma › issues › 5066
Add `upsertMany` CRUD operation · Issue #5066 · prisma/prisma
August 15, 2020 - The upsertMany method would batch-upsert an array of models into the DB. An alternative I came up with is using something like this: const requests = items.map(item => prisma.myModel.upsert(item)) await prisma.$transaction(requests)
Author prisma
GitHub
github.com › prisma › prisma › issues › 10362
`upsertMany()` functionality for bulk upsert · Issue #10362 · prisma/prisma
November 20, 2021 - e.g. to upsert 100 records, 50 of which already exist in the DB, Prisma will currently run a total of 100 SELECT statements, 50 INSERT statements and 50 UPDATE statements. With the described solution flow, this could be reduced to 1 SELECT statement, 1 INSERT statement and 50 UPDATE statements.
Author prisma
GitHub
github.com › prisma › prisma › issues › 18183
Invalid `prisma.***.upsert()` invocation in ... · Issue #18183 · prisma/prisma
March 2, 2023 - Keep getting invalid invocation when using upsert · No response · model Settings { sub String @id darkMode Boolean } const { sub } = res.locals.user as User, [settings] = await prisma.$transaction([ prisma.settings.upsert({ where: { sub }, update: {}, create: { sub, darkMode: false }, }), ]); OS: Ubuntu 20.04 LTS ·
Author prisma
GitHub
github.com › prisma › prisma › issues › 22778
`upsert()` results in P2002 · Issue #22778 · prisma/prisma
January 23, 2024 - Since it is unknown which code will execute first, both code paths use upsert to create the record if it doesn't exist. The issue is that occasionally this throws a PrismaClientKnownRequestError with code P2002 and meta: { modelName: 'Message', target: [ 'id' ] } The record is updated with no errors.
Author prisma