Incorrect relations

I have this Drizzle ORM query:

const projects = await ctx.db.query.syndicationProject.findMany({
        with: {
            entity: {
                with: {
                    members: {
                        with: {
                            member: true,
                        },
                    },
                },
            },
        },
    });


The problem is that "members" under each project.entity is empty, even though the correct rows and references are in the database. You can see how I have defined my schemas in my comment on this post.

The weird thing is, if I change the relation name to "entity" like so:

export const personRelations = relations(person, ({ one, many }) => ({
    members: many(membership, { relationName: "entity" }),
}));


Suddenly I do get the correct result. How can this be? The relation name should be "member", because I want to fetch the nested members. Or am I misunderstanding?

Hopefully you can help me out!
Was this page helpful?