2019-07-19 18:14:13 +02:00
|
|
|
'use strict';
|
|
|
|
|
2019-07-22 09:56:25 +02:00
|
|
|
const storeUtils = require('./utils/store');
|
2019-07-19 18:14:13 +02:00
|
|
|
|
2019-07-22 12:15:54 +02:00
|
|
|
const uidToStoreKey = uid => `groups::${uid}`;
|
|
|
|
|
2019-07-19 18:14:13 +02:00
|
|
|
module.exports = {
|
2019-07-22 12:15:54 +02:00
|
|
|
uidToStoreKey,
|
|
|
|
|
|
|
|
getConfiguration(uid) {
|
|
|
|
const storeKey = uidToStoreKey(uid);
|
2019-07-22 09:56:25 +02:00
|
|
|
return storeUtils.getModelConfiguration(storeKey);
|
2019-07-19 18:14:13 +02:00
|
|
|
},
|
|
|
|
|
2019-07-22 12:15:54 +02:00
|
|
|
setConfiguration(uid, input) {
|
2019-07-19 18:14:13 +02:00
|
|
|
const { settings, metadatas, layouts } = input;
|
|
|
|
|
2019-07-22 12:15:54 +02:00
|
|
|
const storeKey = uidToStoreKey(uid);
|
2019-07-22 09:56:25 +02:00
|
|
|
return storeUtils.setModelConfiguration(storeKey, {
|
|
|
|
uid,
|
|
|
|
isGroup: true,
|
|
|
|
settings,
|
|
|
|
metadatas,
|
|
|
|
layouts,
|
|
|
|
});
|
2019-07-19 18:14:13 +02:00
|
|
|
},
|
|
|
|
|
2019-07-22 12:15:54 +02:00
|
|
|
deleteConfiguration(uid) {
|
|
|
|
const storeKey = uidToStoreKey(uid);
|
|
|
|
return storeUtils.deleteKey(storeKey);
|
|
|
|
},
|
2019-07-26 17:53:03 +02:00
|
|
|
|
|
|
|
async updateUID(oldUID, newUID) {
|
|
|
|
const oldKey = uidToStoreKey(oldUID);
|
|
|
|
const newKey = uidToStoreKey(newUID);
|
|
|
|
|
|
|
|
await storeUtils.setModelConfiguration(oldKey, {
|
|
|
|
uid: oldUID,
|
|
|
|
isGroup: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
return storeUtils.moveKey(oldKey, newKey);
|
|
|
|
},
|
2019-07-19 18:14:13 +02:00
|
|
|
};
|