Просмотр исходного кода

abolish findOneAndUpdateByNsAndKey

mizozobu 6 лет назад
Родитель
Сommit
c832bc8173

+ 5 - 1
src/migrations/20190618055300-abolish-crowi-classic-auth.js

@@ -15,7 +15,11 @@ module.exports = {
 
     // enable passport and delete configs for crowi classic auth
     await Promise.all([
-      Config.findOneAndUpdateByNsAndKey('crowi', 'security:isEnabledPassport', true),
+      Config.findOneAndUpdate(
+        { ns: 'crowi', key: 'security:isEnabledPassport' },
+        { ns: 'crowi', key: 'security:isEnabledPassport', value: JSON.stringify(true) },
+        { upsert: true },
+      ),
       Config.deleteOne({ ns: 'crowi', key: 'google:clientId' }),
       Config.deleteOne({ ns: 'crowi', key: 'google:clientSecret' }),
     ]);

+ 0 - 8
src/server/models/config.js

@@ -188,14 +188,6 @@ module.exports = function(crowi) {
     validateCrowi();
   };
 
-  configSchema.statics.findOneAndUpdateByNsAndKey = async function(ns, key, value) {
-    return this.findOneAndUpdate(
-      { ns, key },
-      { ns, key, value: JSON.stringify(value) },
-      { upsert: true },
-    );
-  };
-
   configSchema.statics.getLocalconfig = function() {
     const env = process.env;