Darkyne
01/26/2022, 10:01 PMconst name = _input_.name ?? undefined;
const categories = _input_.categories ?? undefined;
const games = await prisma.game.findMany({
where: {
AND: {
name: { contains: name, mode: 'insensitive' },
categories: {
some: {
}
}
}
},
I have this query and I'm trying to to check if any category matches one of the categories array (input) how do I map this?Nathaniel Bajo
01/27/2022, 11:21 AMNathaniel Bajo
01/27/2022, 11:21 AMMartijn Burger
01/27/2022, 12:54 PM*select* p."json"->>'email' *as* email *from* "Party" p
in prisma. Something like: db.party.findMany({ select: { json->>'email': true } })
?Friedrich Mäckle
01/27/2022, 1:30 PMFriedrich Mäckle
01/27/2022, 1:30 PMKay Khan
01/27/2022, 2:18 PMReuben Porter
01/27/2022, 3:53 PMconcat
query. Basically we have a user’s table with FirstName
and lastName
, and we’re using a `contains`/`LIKE` search.
I.e if I search “Nathan” it will search firstName and lastName columns for “Nathan”, and if it finds it, return the row(s), great! Likewise if I search “Sainsbury”, it will return the row.
However, should I search “Nathan Sainsbury” I would find no results as “Nathan Sainsbury” is not contained with “Nathan” or “Sainsbury”.
In SQL I’d be able to do something like:
select * from "User"
where concat("firstName", ' ', "lastName") LIKE '%Nathan Sainsbury%';
Is there anyway to do this in Prisma without a raw query?Austin Zentz
01/27/2022, 4:03 PMAustin Zentz
01/27/2022, 4:04 PMReuben Porter
01/27/2022, 4:05 PMAustin Zentz
01/27/2022, 4:05 PMAustin Zentz
01/27/2022, 4:05 PMAustin Zentz
01/27/2022, 4:06 PMReuben Porter
01/27/2022, 4:06 PMAustin Zentz
01/27/2022, 4:06 PMReuben Porter
01/27/2022, 4:07 PMAustin Zentz
01/27/2022, 4:09 PMDarkyne
01/27/2022, 8:25 PMwhere: {
AND: [
...categories!.map((value) => ({ categories: { some: { description: { contains: value } } } })),
]
},
and no, some or every will not suffice (at least not in its most basic form)
hasEvery would be preferable but it seems to only be available to scalar fields or mongodb relations
(I use postgresql)Nathaniel Babalola
01/27/2022, 8:50 PMUser
table and a Transactions
table for storing transactions between users.
The Transactions
table has a from and to field , which should reference the id of the users sending and receiving on User
table.
How can 2 fields/columns reference the same key on another table.
I can't do any of these.
user user @relation(fields: [from, to], references :[id] )
user user @relation(fields: [from, to], references :[id, id] )
Please any help is greatly appreciated.Dan Shapir
01/27/2022, 11:23 PMSELECT * FROM A INNER JOIN B on B.aId = A.id AND B.amount < A.price
or
SELECT * FROM A INNER JOIN B on a.aId = A.id WHERE B.amount < A.price
Meaning your query’s filter parameter is part of the query itself.
I couldn’t figure anyway to do it and it’s crazy… This is a super basic SQL capability박기웅
01/28/2022, 2:50 AMjohngonzalez
01/28/2022, 3:15 AMuser
01/28/2022, 9:30 AMNothing.
01/28/2022, 10:03 AMMichael Buller
01/28/2022, 4:28 PM"Could not find stored procedure 'Case-Clinical.dbo.usp_ProviderSearch'.
I run the query on the database, everything is fine. I run it using prisma and I get that error message. I logged into the database using same user as prisma uses.
// let results = await this.data.$queryRaw<ProviderSearch[]>`exec [dbo].usp_ProviderSearch
// @Search = ${input.search} ,
// @City = ${input.city} ,
// @PostalCode = ${input.postalCode} ,
// @Specialty = ${input.specialty} ,
// @Rating = ${input.rating} ,
// @Latitude = ${input.latitude} ,
// @Longitude = ${input.longitude} ,
// @DistanceMiles = ${input.distanceMiles}
// `
let results = await this.data.$queryRawUnsafe<ProviderSearch[]>(`exec [Case-Clinical].[dbo].usp_ProviderSearch`)
Michael Buller
01/28/2022, 4:28 PMAmol Patel
01/28/2022, 4:50 PM_prisma_migrations
and commenting out the SQL in PR 1 but this is a hack and we are lucky.
Question:
Can prisma migrations be numbered sequentially? Or, is there a migration state file we can generate and check in to our codebase? Very similar to how Django handles migrations. I feel like this is a pretty obvious drawback and am wondering if anyone else has faced this issue. Thanks in advance!Mitchell Amihod
01/28/2022, 6:40 PMMitchell Amihod
01/28/2022, 6:44 PM