Skip to content

Instantly share code, notes, and snippets.

@harryWonder
Created June 10, 2021 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harryWonder/eeeea2e32e26827518b1a8b491e43a12 to your computer and use it in GitHub Desktop.
Save harryWonder/eeeea2e32e26827518b1a8b491e43a12 to your computer and use it in GitHub Desktop.
LD NodeJS & Nginx Newsletter Model
/* Base Model & Mongoose ORM */
const Mongoose = require('mongoose');
/**
* This Class contains the schema required to model a user collection. It also contains reusable methods imported from the mongoose library.
*
* @author Ilori Stephen A
* @returns {Object}
* @name Signup
* @alias Register
* @param {Null}
*
*/
class Newsletters {
newsletters() {
const Schema = Mongoose.Schema;
const UserBluePrint = new Schema({
email: {
type: String,
unqiue: true,
required: [true, "The email field is required"]
},
status: {
type: Number,
default: 1,
/* 0: Pending, 1: Approved, 2: Suspended. */
},
createdAt: {
type: String,
default: global.Date()
},
updatedAt: {
type: String,
default: global.Date()
}
});
const Newsletter = Mongoose.model.Newsletters || Mongoose.model('Newsletters', UserBluePrint);
return Newsletter;
}
}
module.exports = new Newsletters().newsletters();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment