Add getAllFromDatabase service for each config type
parent
4f0cce1b54
commit
8a705e91b9
|
@ -43,6 +43,22 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all core-store config from the db.
|
||||||
|
*
|
||||||
|
* @returns {object} Object with key value pairs of configs.
|
||||||
|
*/
|
||||||
|
getAllFromDatabase: async () => {
|
||||||
|
const coreStore = await strapi.query(coreStoreQueryString).find({ _limit: -1 });
|
||||||
|
let configs = {};
|
||||||
|
|
||||||
|
Object.values(coreStore).map( ({ id, value, ...config }) => {
|
||||||
|
configs[`${configPrefix}.${config.key}`] = { value: JSON.parse(value), ...config };
|
||||||
|
});
|
||||||
|
|
||||||
|
return configs;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import all core-store config files into the db.
|
* Import all core-store config files into the db.
|
||||||
*
|
*
|
||||||
|
|
|
@ -63,6 +63,39 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all role-permissions config from the db.
|
||||||
|
*
|
||||||
|
* @returns {object} Object with key value pairs of configs.
|
||||||
|
*/
|
||||||
|
getAllFromDatabase: async () => {
|
||||||
|
const service =
|
||||||
|
strapi.plugins['users-permissions'].services.userspermissions;
|
||||||
|
|
||||||
|
const [roles, plugins] = await Promise.all([
|
||||||
|
service.getRoles(),
|
||||||
|
service.getPlugins(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const rolesWithPermissions = await Promise.all(
|
||||||
|
roles.map(async role => service.getRole(role.id, plugins))
|
||||||
|
);
|
||||||
|
|
||||||
|
const sanitizedRolesArray = rolesWithPermissions.map(role =>
|
||||||
|
sanitizeEntity(role, {
|
||||||
|
model: strapi.plugins['users-permissions'].models.role,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
let configs = {};
|
||||||
|
|
||||||
|
Object.values(sanitizedRolesArray).map((config) => {
|
||||||
|
configs[`${configPrefix}.${config.type}`] = config;
|
||||||
|
});
|
||||||
|
|
||||||
|
return configs;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import all role-permissions config files into the db.
|
* Import all role-permissions config files into the db.
|
||||||
*
|
*
|
||||||
|
|
|
@ -40,6 +40,22 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all webhook config from the db.
|
||||||
|
*
|
||||||
|
* @returns {object} Object with key value pairs of configs.
|
||||||
|
*/
|
||||||
|
getAllFromDatabase: async () => {
|
||||||
|
const webhooks = await strapi.query(webhookQueryString).find({ _limit: -1 });
|
||||||
|
let configs = {};
|
||||||
|
|
||||||
|
Object.values(webhooks).map( (config) => {
|
||||||
|
configs[`${configPrefix}.${config.id}`] = config;
|
||||||
|
});
|
||||||
|
|
||||||
|
return configs;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import all webhook config files into the db.
|
* Import all webhook config files into the db.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue