I want to write my mongoose model in ES6. Basically replace module.exports
and other ES5 things wherever possible. Here is what I have.
import mongo
Mongoose can natively support es6 classes (since 4.7, and with no transpiler…).
Just write:
const mongoose = require('mongoose')
const { Model, Schema } = mongoose
const schema = new Schema({
type: String,
ip: String,
details: String,
reason: String,
})
class Tenant extends Model {}
module.exports = mongoose.model(Tenant, schema, 'tenant');