How to use the decentraland-server.SQL.raw function in decentraland-server

To help you get started, we’ve selected a few decentraland-server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github decentraland / agora / src / Option / Option.model.ts View on Github external
static async findByPollId(id: string) {
    return this.query(SQL`
      SELECT *
        FROM ${SQL.raw(this.tableName)}
        WHERE poll_id = ${id}`)
  }
}
github decentraland / agora / src / Poll / Poll.queries.ts View on Github external
{ status, type }: { status?: FilterStatus; type?: FilterType } = {
      status: DEFAULT_STATUS,
      type: DEFAULT_TYPE
    }
  ) {
    let statusQuery
    let typeQuery

    if (status === 'active') {
      statusQuery = SQL`closes_at > extract(epoch from now()) * 1000`
    } else if (status === 'expired') {
      statusQuery = SQL`closes_at <= extract(epoch from now()) * 1000`
    }

    if (type === 'district') {
      typeQuery = SQL`token_address LIKE '${SQL.raw(DISTRICT_TOKEN.address)}-%'`
    } else if (type === 'decentraland') {
      typeQuery = SQL`token_address LIKE '0x%'`
    }

    if (statusQuery && typeQuery) {
      return SQL`WHERE ${statusQuery} AND ${typeQuery}`
    } else if (statusQuery) {
      return SQL`WHERE ${statusQuery}`
    } else if (typeQuery) {
      return SQL`WHERE ${typeQuery}`
    } else {
      return SQL``
    }
  },
  findWithAssociations: (whereStatement: SQLStatement = SQL``): SQLStatement =>
github decentraland / agora / src / Poll / Poll.model.ts View on Github external
static async updateBalances(): Promise {
    await this.query(SQL`UPDATE ${SQL.raw(this.tableName)}
        SET balance = COALESCE((${VoteQueries.sumAccountBalanceForPollSubquery()}), 0)`)
  }