Skip to content

How do I pass an array into an SQL query? #906

Description

@moonman239

I'm trying to pass an array of numbers into an UPDATE query. I tried this:

const ids = [0,1,2];
 await sql`
    UPDATE scheduled_notifications
    SET last_sent_at = NOW()
    WHERE id = ANY(${ids}::bigint[])
  `;

but TypeScript doesn't like that "ids" is a "number[]" and not a "Primitive."

What should I do instead?

Please & thank you!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions