round2
This commit is contained in:
@ -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 };
|
||||
|
Reference in New Issue
Block a user