pg#QueryConfig TypeScript Examples

The following examples show how to use pg#QueryConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: container_user_invite_mapper.ts    From Deep-Lynx with MIT License 6 votes vote down vote up
// Below are a set of query building functions. So far they're very simple
    // and the return value is something that the postgres-node driver can understand
    // My hope is that this method will allow us to be flexible and create more complicated
    // queries more easily.
    private createStatement(invite: ContainerUserInvite): QueryConfig {
        return {
            text: `INSERT INTO user_container_invites(origin_user, email, token, container_id, issued) VALUES($1, $2, $3, $4, NOW()) RETURNING *`,
            values: [invite.origin_user, invite.email, invite.token, invite.container!.id!],
        };
    }
Example #2
Source File: db.ts    From livepeer-com with MIT License 6 votes vote down vote up
queryWithOpts<T, I extends any[] = any[]>(
    query: QueryConfig<I>,
    opts: QueryOptions = { useReplica: true }
  ): Promise<QueryResult<T>> {
    const { useReplica = true } = opts;
    if (useReplica && this.replicaPool) {
      return this.replicaPool.query(query);
    }
    return this.pool.query(query);
  }
Example #3
Source File: container_user_invite_mapper.ts    From Deep-Lynx with MIT License 5 votes vote down vote up
private deleteStatement(id: string): QueryConfig {
        return {
            text: `DELETE FROM user_container_invites WHERE id = $1`,
            values: [id],
        };
    }