Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prisma, NextJs, Issue with nested query with nested where Provided Json, expected Int. #1468

Open
JavierTF opened this issue Apr 16, 2023 · 0 comments

Comments

@JavierTF
Copy link

JavierTF commented Apr 16, 2023

This is my first post issue of all my life. I love programming, you're inspiration for me... so, let's begin:

My schema is huge, so i will try to explain:
· 1 guide has many components
· 1 components has many tags
· 1 tag has many aspects
· 1 aspect has many items

but also:
· 1 guide_approvement has fk aspect_id, fk item_id, fk guide_id, fk department_id
· the aspects and the items must recieve a rating

this is the thing: i´m doing pretty well the query but i can´t add many filters, i need select rating active = true AND department_id = userDepartmentId and others, but i just can do well the where id: guide?.id at the beggining

Reading the documentation i tried to do nested where with: where: { table: { is: { field: value ... but i recieve this error "Provided Json, expected Int."

In the following lines you will see errors, it's in purpose, that's i want to approach:

let data = { table: "guide", action: "get", // findUnique body: { where: { // not work id: { is: { id: valueGuide?.id, }, }, }, select: { id: true, date: true, version: true, component_guide: { select: { component: true, }, orderBy: { id: "asc", }, }, tag_guide: { select: { tag: true, }, orderBy: { id: "asc", }, }, aspect_guide: { select: { aspect: true, }, orderBy: { id: "asc", }, }, item_guide: { select: { item: true, }, orderBy: { id: "asc", }, }, guide_approvement: { select: { comment: true, aspect_guide_id: true, item_guide_id: true, rating: { select: { value: true, where: { // not work is: { active: true, }, }, }, }, }, where: { // not work departament_id: user.departament.id, }, }, }, }, };

prisma.table.findUnique(url, data)

Hope your help, thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant