/**
* @memberof Myintranet.Services
* @inheritDoc
*/
class Service {
constructor(Model) {
// if (!Model) {
// throw new Error("Main model is reauired, cant create a crudService without a data model");
// }
this.model = Model;
}
/**
*
*/
getAll(params) {
return this.model.findAll(params || {});
}
/**
*
* @param {*} id
*/
getOne(id) {
return this.model.findOne({ where: { id } });
}
/**
*
* @param {object} where
*/
getBy(where) {
return new Promise((resolve, reject) => {
});
}
/**
*
* @param {*} id
* @param {*} data
*/
update(request) {
return this.model.update(data, { where: { id } });
}
/**
*
* @param {*} id
*/
delete(id) {
// let { id } = data;
return this.model.destroy({ where: { id } });
}
/**
*
* @param {*} data
*/
add(request) {
console.log(request.db)
let connected = request.user;
let data = request.body;
return this.model.create(data);
}
}
module.exports = Service;