Skip to content
Discussion options

You must be logged in to vote

Object keys are responsible for determining which variables you will use in your code and which keys will be inferred from the schema. Names inside type functions are responsible for the names in the database. It's useful when you want to have camelCase in your code and snake_case in the database, or even name them differently

Just a small example

const users = pgTable('users', {
  id: serial('id').primaryKey(),
  codeName: text('full_name'),
  userPhone: varchar('phone', { length: 256 }),
});

But we have plans to make the string inside the column function an optional field and just use the key for the database name

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@josvanos
Comment options

@cr101
Comment options

@josvanos
Comment options

Answer selected by josvanos
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants