salix/services/item/common/models/item-niche.js

24 lines
579 B
JavaScript
Raw Normal View History

module.exports = Self => {
/* Self.validateAsync('warehouseFk', validateWarehouseUniqueness, {
message: `The warehouse can't be repeated`
});
async function validateWarehouseUniqueness(err, done) {
let where = {
itemFk: this.itemFk,
warehouseFk: this.warehouseFk
};
if (this.id != null)
where.id = {neq: this.id};
let warehouseExists = await Self.findOne({where: where});
console.log(warehouseExists);
if (warehouseExists)
err();
done();
} */
2018-02-20 11:25:51 +00:00
};