You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Guys, I'm using this package to make full text searches in my current system. I've followed the steps on how to implement the materialized views suggested on the documentation with no luck. I'm getting the following error
TypeError: Cannot read property 'field' of undefined
at Object.keys.forEach.key (~/proj/node_modules/pg-search-sequelize/lib/queryGenerator.js:100:59)
at Array.forEach (native)
at QueryGenerator.where (~/proj//node_modules/pg-search-sequelize/lib/queryGenerator.js:97:29)
at Function.search (~/proj/node_modules/pg-search-sequelize/lib/searchModel.js:82:8)
I've been trying to debug to see if I've implemented incorrectly but, it looks very alike to the example provided. I'll post the corresponding code below:
'use strict';letSearchModel=require("pg-search-sequelize");module.exports=(sequelize,DataTypes)=>{constuser=sequelize.define('user',{name: {type: DataTypes.STRING},email: {type: DataTypes.STRING,allowNull: false,unique: true},password: {type: DataTypes.STRING,allowNull: false},role_id: {allowNull: false,type: DataTypes.INTEGER,references: {model: "role",key: "id"}},profile_pic: {type: DataTypes.STRING}});user.associate=(models)=>{user.belongsTo(models.role,{foreignKey: 'role_id'})user.hasMany(models.director,{foreignKey: 'user_id',onDelete: 'CASCADE'})user.hasMany(models.teacher,{foreignKey: 'user_id',onDelete: 'CASCADE'})user.hasMany(models.student,{foreignKey: 'user_id',onDelete: 'CASCADE'})}user.hook("beforeCreate","passwordHashing",(user,options)=>{lethashedPassword=passwordHelper.hash(user.password)returnuser.password=hashedPassword})user.hook("afterCreate","emailNotification",(user,options)=>{// Asynchronous way to send an email without// interrupting the flow of the systemMailer.sendPasswordWelcomeTemplate(user).then(console.log).catch(console.log)returnuser;})returnuser;};
Materialized view implementation
'use strict';constmodels=require("../models");letSearchModel=require("pg-search-sequelize");module.exports=(sequelize,DataTypes)=>{letDirectorMaterializedView=sequelize.define('DirectorMaterializedView',{id: {type: DataTypes.INTEGER,primaryKey: true,autoIncrement: true},name: DataTypes.STRING,email: DataTypes.TEXT,profile_pic: DataTypes.TEXT},{tableName: 'director_materialized_view',timestamps: false,search: true,defaultScope: {attributes: {exclude: ['profile_pic','id']}},referenceModel: 'user'// The model for which we're defining the materialized view});returnDirectorMaterializedView;};
Hi Guys, I'm using this package to make full text searches in my current system. I've followed the steps on how to implement the materialized views suggested on the documentation with no luck. I'm getting the following error
I've been trying to debug to see if I've implemented incorrectly but, it looks very alike to the example provided. I'll post the corresponding code below:
Express router
User.js (reference model)
Materialized view implementation
Index.js
Sequelize migration
Any help with this will be greatly appreciated.
Extra information:
The text was updated successfully, but these errors were encountered: