relations help
how can i have a many-to-many relation for example a user can have multiple followers and can follow multple users
this seem to not work and im told to give more information about relation "user.followers"
export const users = pgTable(
'users',
{
id: text('id').primaryKey().notNull(),
name: text('name'),
bio: text('bio').default("I Don''t Need A Bio, I''m A Developer"),
email: text('email'),
avatar: text('avatar').default('https://i.imgur.com/6VBx3io.png'),
bannerImage: text('bannerImage').default('https://i.imgur.com/6VBx3io.png'),
createdAt: timestamp('created_at', { precision: 3, mode: 'string' }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { precision: 3, mode: 'string' }).notNull(),
role: role('role'),
preferences: jsonb('preferences'),
auth: jsonb('auth'),
invitedBy: text('invitedBy'),
},
(table) => {
return {
emailKey: uniqueIndex('users_email_key').on(table.email),
};
},
);
export const userRelations = relations(users, ({ one, many }) => ({
invitee: one(users, {
fields: [users.invitedBy],
references: [users.id],
}),
// followers: many(users, {
// relationName: 'followers',
// }),
// following: many(users, {
// relationName: 'following',
// }),
posts: many(post),
comments: many(comment),
likes: many(like),
}));export const users = pgTable(
'users',
{
id: text('id').primaryKey().notNull(),
name: text('name'),
bio: text('bio').default("I Don''t Need A Bio, I''m A Developer"),
email: text('email'),
avatar: text('avatar').default('https://i.imgur.com/6VBx3io.png'),
bannerImage: text('bannerImage').default('https://i.imgur.com/6VBx3io.png'),
createdAt: timestamp('created_at', { precision: 3, mode: 'string' }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { precision: 3, mode: 'string' }).notNull(),
role: role('role'),
preferences: jsonb('preferences'),
auth: jsonb('auth'),
invitedBy: text('invitedBy'),
},
(table) => {
return {
emailKey: uniqueIndex('users_email_key').on(table.email),
};
},
);
export const userRelations = relations(users, ({ one, many }) => ({
invitee: one(users, {
fields: [users.invitedBy],
references: [users.id],
}),
// followers: many(users, {
// relationName: 'followers',
// }),
// following: many(users, {
// relationName: 'following',
// }),
posts: many(post),
comments: many(comment),
likes: many(like),
}));this seem to not work and im told to give more information about relation "user.followers"