aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/runner/runner.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-12 10:53:46 +0200
committerChocobozzz <me@florianbigard.com>2023-07-12 10:56:07 +0200
commitd959b763f089ed4c1087aa4aeb824a8ef6743111 (patch)
treef4b5e77757fde022c91e415906bcf4619f8ec31c /server/models/runner/runner.ts
parent88cde4392a27d5d37685a471f9bf83d537282c43 (diff)
downloadPeerTube-d959b763f089ed4c1087aa4aeb824a8ef6743111.tar.gz
PeerTube-d959b763f089ed4c1087aa4aeb824a8ef6743111.tar.zst
PeerTube-d959b763f089ed4c1087aa4aeb824a8ef6743111.zip
Avoid duplicate runner names
Diffstat (limited to 'server/models/runner/runner.ts')
-rw-r--r--server/models/runner/runner.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/server/models/runner/runner.ts b/server/models/runner/runner.ts
index 1ef0018b4..4d07707d8 100644
--- a/server/models/runner/runner.ts
+++ b/server/models/runner/runner.ts
@@ -16,6 +16,10 @@ import { CONSTRAINTS_FIELDS } from '@server/initializers/constants'
16 }, 16 },
17 { 17 {
18 fields: [ 'runnerRegistrationTokenId' ] 18 fields: [ 'runnerRegistrationTokenId' ]
19 },
20 {
21 fields: [ 'name' ],
22 unique: true
19 } 23 }
20 ] 24 ]
21}) 25})
@@ -74,6 +78,14 @@ export class RunnerModel extends Model<Partial<AttributesOnly<RunnerModel>>> {
74 return RunnerModel.findOne(query) 78 return RunnerModel.findOne(query)
75 } 79 }
76 80
81 static loadByName (name: string) {
82 const query = {
83 where: { name }
84 }
85
86 return RunnerModel.findOne(query)
87 }
88
77 static listForApi (options: { 89 static listForApi (options: {
78 start: number 90 start: number
79 count: number 91 count: number