aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/server/plugin.ts19
1 files changed, 9 insertions, 10 deletions
diff --git a/server/models/server/plugin.ts b/server/models/server/plugin.ts
index c72846343..53b6227d7 100644
--- a/server/models/server/plugin.ts
+++ b/server/models/server/plugin.ts
@@ -1,5 +1,5 @@
1import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { FindAndCountOptions, json } from 'sequelize' 2import { FindAndCountOptions, json, QueryTypes } from 'sequelize'
3import { AllowNull, Column, CreatedAt, DataType, DefaultScope, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' 3import { AllowNull, Column, CreatedAt, DataType, DefaultScope, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
4import { MPlugin, MPluginFormattable } from '@server/typings/models' 4import { MPlugin, MPluginFormattable } from '@server/typings/models'
5import { PeerTubePlugin } from '../../../shared/models/plugins/peertube-plugin.model' 5import { PeerTubePlugin } from '../../../shared/models/plugins/peertube-plugin.model'
@@ -212,18 +212,17 @@ export class PluginModel extends Model<PluginModel> {
212 } 212 }
213 213
214 static storeData (pluginName: string, pluginType: PluginType, key: string, data: any) { 214 static storeData (pluginName: string, pluginType: PluginType, key: string, data: any) {
215 const query = { 215 const query = 'UPDATE "plugin" SET "storage" = jsonb_set(coalesce("storage", \'{}\'), :key, :data::jsonb) ' +
216 where: { 216 'WHERE "name" = :pluginName AND "type" = :pluginType'
217 name: pluginName,
218 type: pluginType
219 }
220 }
221 217
222 const toSave = { 218 const jsonPath = '{' + key + '}'
223 [`storage.${key}`]: data 219
220 const options = {
221 replacements: { pluginName, pluginType, key: jsonPath, data: JSON.stringify(data) },
222 type: QueryTypes.UPDATE
224 } 223 }
225 224
226 return PluginModel.update(toSave, query) 225 return PluginModel.sequelize.query(query, options)
227 .then(() => undefined) 226 .then(() => undefined)
228 } 227 }
229 228