many to many self reference

I'm trying to define "follows" & "followers" relations on a user entity. Obviously this is a many to many relation, but how to I define both "edges" in my relation?

const userToUsers = table("users", {
  userId: text(),
  followsUserId: text(),
}); // rather pseudo-ish code

const userRelations = relations(users, ({many}) => ({
  follows: many(userToUsers),
  followers: many(userToUsers), // hmmm... distinct from follows how?
}));


I've seen many takes a config param relationName but I don't see where I can define that the relation "follows" references followsUserId and "followers" references userId?
Was this page helpful?