mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
450 B
21 lines
450 B
import { defineRelations } from 'drizzle-orm'
|
|
import * as schema from './schema.js'
|
|
|
|
export const relations = defineRelations(schema, (r) => ({
|
|
users: {
|
|
groups: r.many.groups({
|
|
from: r.users.id.through(r.userGroups.userId),
|
|
to: r.groups.id.through(r.userGroups.groupId)
|
|
})
|
|
},
|
|
groups: {
|
|
members: r.many.users()
|
|
},
|
|
userKeys: {
|
|
user: r.one.users({
|
|
from: r.userKeys.userId,
|
|
to: r.users.id
|
|
})
|
|
}
|
|
}))
|