Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const userSchema = new mongoose.Schema({
- email: { type: String, unique: true, lowercase: true, trim: true },
- password: String,
- role: [ { type: mongoose.Schema.Types.ObjectId, ref: 'Role' } ]
- });
- const User = mongoose.model('User', userSchema);
- export default User;
- const roleSchema = new mongoose.Schema({
- description: { type: String },
- });
- const Role = mongoose.model('Role', roleSchema);
- export default Role;
- abstract class BaseCtrl {
- abstract model: any;
- // Example of read using get all
- getAll = (req, res) => {
- this.model.find({}, (err, docs) => {
- if (err) { return console.error(err); }
- res.json(docs);
- });
- }
- export default BaseCtrl;
Add Comment
Please, Sign In to add comment