mongoose-elasticsearch-xp
mongoose-elasticsearch-xp copied to clipboard
[Bag] TypeError: Cannot read property 'toLowerCase' of undefined
require('mongoose-double')(mongoose);
const Schema = mongoose.Schema;
const Double = Schema.Types.Double;
const productSchema = new Schema(
{
isCloseout: { type: Boolean, required: true, index: true, default: false },
isCaution: { type: Boolean, required: true, index: true, default: false },
isOnDemand: { type: Boolean, required: true, index: true, default: false },
isHazmat: { type: Boolean, required: true, index: true, default: false },
productId: { type: String, required: true, index: true, es_indexed: true, es_type: 'text' },
productName: { type: String, required: true, index: true, es_indexed: true, es_type: 'text' },
slug: { type: String, required: true, index: true, unique: true, es_indexed: true, es_type: 'keyword' },,
priceMax: { type: Double, index: true },
priceMin: { type: Double, index: true },
status: { type: String, index: true, es_indexed: true, es_type: 'text' }
},
{ timestamps: true }
);
there is error in function because It can't detect Double type instance for field priceMax and priceMin even if it's not marked as es_index: true
module.exports.getType = function getType(path) {
return (path.caster && path.caster.instance
? path.caster.instance
: path.instance
).toLowerCase();
};