Skip to content

How to pass array of timestamps with intervals at params? #2684

Open
@ramirobg94

Description

@ramirobg94

We are trying to build this query


    const { sessionIds, moderatorIds, payouts, createdAts, publicAts } =
      normalizedData;

    const usersIds = ['uuid0, 'uuid1']
    const createdAts = ['NOW()', 'NOW()']
    const publicAts = [`NOW() + '${user0.delay} seconds'`, `NOW() + '${user1.delay} seconds'`]
    
    return {
      text: `
      INSERT INTO offers (user_id, created_at, public_at) 
      SELECT * 
      FROM UNNEST ($1::uuid[], $2::timestamp[], $3::timestamp[]) 
      RETURNING id, user_id`,
      values: [usersIds, createdAts, publicAts],
    };

but the system returns

invalid input syntax for type timestamp: "NOW() + interval '10 seconds'"

Does anyone knows the right way to build this query

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions