Skip to content

Reverse transform of column names when inserting or updating #16

Closed
@davojan

Description

@davojan

Transforming column names in both ways would greatly improved ergonomics of the library. Consider this example:

const sql = postgres({
  transform: {
    column: postgres.toCamel,
  },
}) 
const entity = {
  appliedAt: new Date,  // db column name is "applied_at"
}
// error: column "appliedat" of relation "some_table" does not exist
sql`INSERT INTO some_table ${sql(entity)}`

Transform option should work both ways, I think. May be configured like this:

{
  transform: {
    column: {
      fromDb: postgres.toCamel,
      toDb: postgres.toSnake,
    },
  },
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions