This commit is contained in:
2024-01-23 19:00:57 -05:00
parent 173277cc8b
commit c136b20112
38 changed files with 257 additions and 964 deletions

View File

@ -1,6 +1,6 @@
"use strict";
const { Sequelize, DataTypes } = require("sequelize");
const { sequelize } = require("../mySQL");
const { sequelize } = require("../mySql");
const { isAlphaNumericwithSpaces } = require('../../functions/validateData')
//sequelize.sync();
@ -72,59 +72,6 @@ const locationModel = sequelize.define(
}
);
async function getLocation() {
const location = await locationModel.findAll();
return location;
}
locationModel.sync();
async function addLocation(name, added_by, description) {
const location = await locationModel.create({
name: name,
added_by: added_by,
description: description,
});
}
async function updateLocation(id, name, added_by, description) {
const location = await locationModel.update(
{
name: name,
added_by: added_by,
description: description,
},
{
where: {
id: id,
},
}
);
}
async function deleteLocation(id) {
//delete by id
const location = await locationModel.destroy({
where: {
id: id,
},
});
}
async function getLocationById(id) {
const location = await locationModel.findAll({
where: {
id: id,
},
});
return location;
}
module.exports = {
locationModel,
getLocation,
addLocation,
updateLocation,
deleteLocation,
getLocationById,
};
module.exports = { locationModel };