Closed AmruthPillai closed 6 days ago
It's specifically because of this line: https://github.com/adamjkb/bark/blob/eb664d11c833719a5f63ea7a9c73fb236d15f57d/packages/prisma-extension-bark/src/create/create-child.js#L68C4-L77C6
Where there is a query on just path. Instead, if it would be possible to reuse the same query that was provided in where
or node
, that just might work... I'm not too sure if it has other consequences though.
From a technical perspective path is required to be unique because we can't have two nodes pointing to same location in the tree. If my assumptions are correct what you're trying to do here is to create multiple roots, each representing an organization. Essentially you would no longer need locationId, at least not on the tree model; you might need to make make note of the root path on related models.
Hopefully that makes sense!
Ah, I see. That makes sense. I still would have location ID as we use it for other relations, but basically the path
field would be the only universal field across the database. And since everyone would be creating multiple "root" nodes or children of them, it should be fine.
Thank you for explaining the construct :) Much appreciated!
Hey there, I faced an issue when implementing the Bark extension with our app.
I see that
path
is required to be a unique field across the database for Bark to work as expected, but the thing is, we have multiple organisations under the same database (not so multi-tenant, but just B2B). So because of this, I had to remove the unique constraint onpath
and set a@@unique([path, locationId])
constraint instead, but this seems to break the implementation of createChild as it tries to insert a row using findUnique:Is there a work around to this?