aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/miscs/sql.ts
blob: 204ff5163f463e316c647479837cdc869af5149d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import * as Sequelize from 'sequelize'

function getSequelize (serverNumber: number) {
  const dbname = 'peertube_test' + serverNumber
  const username = 'peertube'
  const password = 'peertube'
  const host = 'localhost'
  const port = 5432

  return new Sequelize(dbname, username, password, {
    dialect: 'postgres',
    host,
    port,
    operatorsAliases: false,
    logging: false
  })
}

function setActorField (serverNumber: number, to: string, field: string, value: string) {
  const seq = getSequelize(serverNumber)

  const options = { type: Sequelize.QueryTypes.UPDATE }

  return seq.query(`UPDATE actor SET "${field}" = '${value}' WHERE url = '${to}'`, options)
}

export {
  setActorField
}