const mongoose = require('mongoose'); const Schema = mongoose.Schema; const tools = require('../tools/general'); mongoose.Promise = global.Promise; mongoose.level = "F"; // Resolving error Unknown modifier: $pushAll mongoose.plugin(schema => { schema.options.usePushEach = true }); const MailingListSchema = new Schema({ idapp: { type: String, }, email: { type: String, trim: true, }, name: { type: String, trim: true, }, surname: { type: String, trim: true, }, lastid_newstosent: { type: String } }); MailingListSchema.statics.getFieldsForSearch = function () { return ['name', 'surname', 'email'] }; MailingListSchema.statics.executeQueryTable = function (idapp, params) { params.fieldsearch = this.getFieldsForSearch(); return tools.executeQueryTable(this, idapp, params); }; MailingListSchema.statics.findAllIdApp = function (idapp) { const MailingList = this; const myfind = { idapp }; // Extract only the Teacher where in the users table the field permissions is set 'Teacher' bit. return MailingList.find(myfind, (err, arrrec) => { return arrrec }); }; const MailingList = mongoose.model('MailingList', MailingListSchema); module.exports = { MailingList };