aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/models/shared/query.ts
blob: 036cc13c6aec131168ef5551cc7b5d7fea3732b5 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                                   
import { BindOrReplacements, QueryTypes } from 'sequelize'
import { sequelizeTypescript } from '@server/initializers/database'

function doesExist (query: string, bind?: BindOrReplacements) {
  const options = {
    type: QueryTypes.SELECT as QueryTypes.SELECT,
    bind,
    raw: true
  }

  return sequelizeTypescript.query(query, options)
            .then(results => results.length === 1)
}

export {
  doesExist
}