How can I make reusable columns then building schema?

If I save part of column in variable
const username = varchar('username', { length: 30 }).unique().notNull()
const username = varchar('username', { length: 30 }).unique().notNull()
and then add something
const username_reference = username.references(() => userSchema.username, { onUpdate: 'cascade' })
const username_reference = username.references(() => userSchema.username, { onUpdate: 'cascade' })
It will change first one to It changes objects properties instead of making copy and that's reasonable but I need to make copy and can't figure out how
2 Replies
piechart
piechart9mo ago
Make username a function instead of a variable
Icemourne
IcemourneOP9mo ago
that's great solution thx
Want results from more Discord servers?
Add your server