I am currently trying to pass options to a Sequelize hook, but when I try to access the passed options within the hook, they are always undefined. Anyone got an idea what I am overseeing?
Here's the query:
db.customer.findAll({
where: searchObject,
offset: offset,
limit: limit,
order: orderOptions
}, {
user: req.user
}).then(customers => {
// more code here
And here's the model including the hook definition:
const db = require("../server/database");
const Sequelize = require('sequelize');
const Op = Sequelize.Op;
module.exports = function (sequelize, Sequelize) {
var Customer = sequelize.define('customer', {
id: {
autoIncrement: true,
primaryKey: true,
allowNull: false,
type: Sequelize.INTEGER
},
salutation: {
type: Sequelize.TEXT
},
title: {
type: Sequelize.TEXT
},
firstName: {
type: Sequelize.TEXT
},
lastName: {
type: Sequelize.TEXT
}
}, {
freezeTableName: true
});
Customer.beforeFindAfterExpandIncludeAll((instance, options) => {
console.log(options);
});
return Customer;
}