- Create Newsletter Page: MailingList (without the class style, using Gulp tasks)#94
This commit is contained in:
59
src/server/models/mailinglist.js
Normal file
59
src/server/models/mailinglist.js
Normal file
@@ -0,0 +1,59 @@
|
||||
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 };
|
||||
Reference in New Issue
Block a user