FNDEVVE
Explore posts from serversDTDrizzle Team
•Created by FNDEVVE on 8/2/2024 in #help
findMany conditional select one-to-one relation
Hello. I am switching to Drizzle from Supabase ORM and it's very good. However I got some issues, in findMany query like this:
return this.drizzleService.db.query.Client.findMany({
columns: CLIENT_QUERY,
with: {
Documents: {
columns: DOCUMENT_QUERY,
},
SharedClients: {
columns: SHARED_CLIENT_QUERY,
with: {
User_sharedWithId: {
columns: PARTIAL_USER_QUERY,
},
},
where: eq(SharedClient.ownerId, userId),
},
User: {
columns: PARTIAL_USER_QUERY,
// where: ne(Client.ownerId, userId),
},
},
where: or(
eq(Client.ownerId, userId),
inArray(
Client.id,
this.drizzleService.db
.select({ clientId: SharedClient.clientId })
.from(SharedClient)
.where(eq(SharedClient.sharedWithId, userId)),
),
),
});
I need to return User only when owner !== current user. I can't find a way to do it. This is how relations look:
export const ClientRelations = relations(Client, ({ one, many }) => ({
Documents: many(Document),
User: one(User, {
fields: [Client.ownerId],
references: [User.id],
}),
SharedClients: many(SharedClient),
}));
I found someone with similar issue here: https://discord.com/channels/1043890932593987624/11771898925859635602 replies
Railway Strapi
Hi. It's taken me entire day and I think I am getting close. I deployed Strapi with postgres on Railway - everything is okay. First issue was getting that thing to be in development mode so I can add new content-types, I did it by modifying package.json like in this tutorial: https://dev.to/candidosales/deploying-strapi-4-to-railway-589b
Everything worked till first "rebuild". DB is wiped, starting from 0. I read about this issue and I really have no idea what to do. Even if I did data transfer from local version like this: https://docs.strapi.io/dev-docs/data-management/transfer there would be schema issues (for example there wouldn't be "post" types created). I have truly no idea what to do.
41 replies