Spent hours trying to figure this out - I\'m adding a new Model to my app but it\'s failing with \"TypeError: List.find is not a function\". I have another model, Items, th
To import model instance and call method, for example
modelfile.js
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const NotificationSchema = new Schema({
count: Number,
color: String,
icon: String,
name: String,
date: {type: Date, default: Date.now },
read: Boolean
});
module.exports = mongoose.model('notifications', NotificationSchema);
queryfile.js
const Notification = require('./models/model-notifications');
function totalInsert(online) {
let query = { name: 'viewed count' };
Notification.find(query,(err,result)=>{
if(!err){
totalCount.count = online + result.length;
totalCount.save((err,result)=>{
if(!err){
io.emit('total visitor', totalCount);
}
});
}
});
}