implement mapping update
This commit is contained in:
@@ -70,13 +70,21 @@ const getResourceMappings = () => {
|
||||
};
|
||||
|
||||
const getMappingsFromDatabase = () => {
|
||||
return db.officeResourceMapping.findAll();
|
||||
return db.officeResourceMapping.findAll({order: [['id']]});
|
||||
};
|
||||
|
||||
const deleteMappingById = (id) => {
|
||||
return db.officeResourceMapping.destroy({where: {id}});
|
||||
};
|
||||
|
||||
const updateMappingById = (id, mapping) => {
|
||||
if (mapping.id) {
|
||||
delete mapping.id;
|
||||
}
|
||||
|
||||
return db.officeResourceMapping.update(mapping, {where: {id}});
|
||||
};
|
||||
|
||||
const saveNewMappingToDatabase = (mapping) => {
|
||||
return db.officeResourceMapping.findOrCreate({where: {...mapping}, defaults: {...mapping}});
|
||||
};
|
||||
@@ -88,4 +96,5 @@ module.exports = {
|
||||
getResourceMappings,
|
||||
saveNewMappingToDatabase,
|
||||
deleteMappingById,
|
||||
updateMappingById,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user