Michael Dausmann
08/08/2021, 7:17 AMPatrick
08/08/2021, 8:12 AMconst users = await prisma.users.findMany({
where: {
name: // not null
}
})
Halvor
08/08/2021, 12:01 PMAayush Rajvanshi
08/08/2021, 4:14 PMHalvor
08/08/2021, 6:19 PMmodel User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
username String @unique
password String
userUUID UserUUID?
}
model UserUUID {
id String @id @default(uuid())
user User @relation(fields: [userId], references: [id])
userId Int @unique
}
I want to add an entry to UserUUID if one is not present for the provided username, how can i achieve that?
I tried with the following but it complains about not being able to uniquely identify a user.
await prisma.userUUID.upsert({
where: {
user: {
username: username.toLowerCase()
}
},
update: {},
create: {
user: {
connect: {
username: username.toLowerCase()
}
}
}
});
Anyone knows how i can acheive this? Reason for having a UserUUID is that it should not always be present for every user, only users that have activated that feature.Dev__
08/08/2021, 7:10 PMtransaction
comparable with Promise.all()
, if yes, does multiple prisma queries with with Promise.all()
?Caleb Clark
08/08/2021, 8:59 PMCaleb Clark
08/08/2021, 9:00 PMOrigin
08/09/2021, 7:51 AMMateusz Żmijewski
08/09/2021, 10:15 AMPaul
08/09/2021, 12:32 PM{
parentId: null,
userId: 1234
deletedAt: null,
filterSize: {
{ filterSize: { lte: 199 }, },
OR: { filterSize: { gte: 200 } }, { filterSize: { lte: 799 } },
OR: { filterSize: { gte: 800 } }
}
}
Docs: https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#and
Maybe something like:
AND: {
OR: [
{ filterSize: { lte: 199 }, },
{ filterSize: { gte: 200 } }, { filterSize: { lte: 799 } },
{ filterSize: { gte: 800 } }
]
}
Alexei Snisarenko
08/09/2021, 1:57 PMDaniel Sieradski
08/09/2021, 6:22 PMDaniel Sieradski
08/09/2021, 6:23 PMDaniel Sieradski
08/09/2021, 6:25 PMTomas Jais
08/09/2021, 7:57 PMChip Clark
08/09/2021, 8:24 PMLicense: {
some: {
AND: [
{
LicenseTypeID: 2
},
{
LicenseTypeID: 3
}
]
}
There are records that meet the criteria, but this returns nothing.
Any suggestions how to get the "some" to work with the AND?Paul
08/09/2021, 8:31 PMdhatGuy
08/09/2021, 11:33 PMinclude
return an object instead of an array of objects?prisma chobo
08/10/2021, 12:21 AMwarn(prisma-client) Already 10 Prisma Clients are actively running.
user
08/10/2021, 2:50 AMhayes
08/10/2021, 4:13 AMNditah Samweld
08/10/2021, 8:18 AMNathaniel Babalola
08/10/2021, 8:57 AMmodel Passport {
passportId Int @id @default(autoincrement())
passportNo String
nationality String
issuingCountry String
expiryDate DateTime
gender String
firstName String
lastName String
otherNames String
dateOfBirth String
isTravelCompanion Boolean?
userId Int? // relation scalar field (used in the `@relation` attribute below)
user User? @relation(fields: [userId], references: [id])
//Passport relation
traveller Traveller?
@@map(name: "passport")
}
model Traveller {
travellerId Int @id @default(autoincrement())
title String
firstName String
lastName String
countryCode String
phoneNo String
address String
state String
country String
bookingRef String
travellerType String? @default("adult")
price String
currency String
isUser Boolean @default(false)
userId Int? // relation scalar field (used in the '@relation()` attribute below)
user User? @relation(fields: [userId], references: [id])
flightBooking FlighBooking @relation(fields: [bookingRef], references: [bookingRef])
// passport relations
passportId Int
passport Passport @relation(fields: [passportId], references: [passportId])
@@map(name: "traveller")
}
but it shows this error when i run migrate,
Error:
:warning: We found changes that cannot be executed:
`• Step 1 Added the required column passportId
to the traveller
table without a default value. There are 15 rows in this table, it is not possible to execute this step.`
can someone please tell where I went wrong ?Slackbot
08/10/2021, 9:23 AMOrigin
08/10/2021, 9:39 AMPaul
08/10/2021, 10:23 AMselect * from DamFile
where deletedAt is null
and (filterSize between 1 and 199 or filterSize between 200 and 799 or filterSize >= 800);
With this JS Object:
AND: [
{ OR: [{ AND: [{ filterSize: { gt: 0 } }, { filterSize: { lte: 199 } }] }] },
{ OR: [{ AND: [{ filterSize: { gte: 200 } }, { filterSize: { lte: 799 } }] }] },
{ OR: [{ filterSize: { gte: 800 } }] },
],
Unfortunately I'm not getting any results. Am I able to do complex queries like this using nested conditionals?
ThanksNathaniel Babalola
08/10/2021, 11:24 AMGelo
08/10/2021, 11:36 AMNathaniel Babalola
08/10/2021, 11:57 AMconst id = req.user.id;
const myBookings = await prisma.traveller.findMany({
where: {
userId: id
},
select: {
flightBooking: true
}
});
Hi pls I have this query, but there are multiple travellers
that may have the same flightBooking
, so it would return the same flightBooking
details multiple times if different travellers have it.
Is there a way I can optimize this query to return just one instance of flightBooking
or not duplicate it if it has already returned it?