diff options
Diffstat (limited to 'server/models/shared/query.ts')
-rw-r--r-- | server/models/shared/query.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/server/models/shared/query.ts b/server/models/shared/query.ts new file mode 100644 index 000000000..036cc13c6 --- /dev/null +++ b/server/models/shared/query.ts | |||
@@ -0,0 +1,17 @@ | |||
1 | import { BindOrReplacements, QueryTypes } from 'sequelize' | ||
2 | import { sequelizeTypescript } from '@server/initializers/database' | ||
3 | |||
4 | function doesExist (query: string, bind?: BindOrReplacements) { | ||
5 | const options = { | ||
6 | type: QueryTypes.SELECT as QueryTypes.SELECT, | ||
7 | bind, | ||
8 | raw: true | ||
9 | } | ||
10 | |||
11 | return sequelizeTypescript.query(query, options) | ||
12 | .then(results => results.length === 1) | ||
13 | } | ||
14 | |||
15 | export { | ||
16 | doesExist | ||
17 | } | ||