Skip to content

Using Postgres functions, like NOW(), in query helpers #63

Closed
@jamiesyme

Description

@jamiesyme

Consider the code:

const fields = {
  name: 'John Doe',
  created_at: ...
};
await sql`
  INSERT INTO users ${sql(fields)}
`;

What would I use for created_at to send NOW()?

I know I could probably use the following, but my hope is to keep the SQL compact with the dynamic query helper:

await sql`
  INSERT INTO users (
    name,
    created_at
  ) VALUES (
    ${fields.name},
    NOW()
  )
`;

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions