diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-28 10:32:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-28 10:32:40 +0200 |
commit | fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58 (patch) | |
tree | bd626648077f84fb4628af3a37acf260597fa0ef /server/models/shared/query.ts | |
parent | f68d1cb6ac4aa4fb563b9eeb831fccffee260b2f (diff) | |
download | PeerTube-fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58.tar.gz PeerTube-fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58.tar.zst PeerTube-fa47956ecf51a6d5d10aeb25d2e4db3da90c7d58.zip |
Filter host for channels and playlists search
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 | } | ||