text: // database/models/Account.model.js
  const mongoose  = require('mongoose');
  const Schema    = mongoose.Schema;
  const ObjectId  = Schema.Types.ObjectId;
  const Mixed     = Schema.Types.Mixed;
  
  const APP_PATH = process.env.PWD;
  
  
  /* requires */
  
  
  //
  // s c h e m a :
  //
  const STATUS_ENUM = [ 'active', 'inactive', 'hidden', 'deleted' ];
  const TYPE_ENUM   = [ 'poststick', 'todo', 'list' ];
  
  const noteSchema = new Schema(
    { // attributes
      title: {
        //alias: "",
        type: String,
        select: true,
        required: false,
        index: false,
        unique: false,
        validate: {
          validator: function(value) {
            return true;
          },
          message: props => props.value+" is not a valid!"
        },
        trim: true,
        get: v => v, 
        set: v => v,
        default: function () {
          return "New note " + Date.now();
        }
      },
      key: {
        alias: "code",
        type: String,
        select: false,
        required: true,
        index: true,
        unique: true,
        validate: {
          validator: function(value) {
            return true;
          },
          message: props => props.value+" is not a valid!"
        },
        trim: true,
        get: v => v, 
        set: v => v
      },
      status: {
        //alias: "",
        type: String,
        select: true,
        required: true,
        index: false,
        unique: false,
        get: v => v, 
        set: v => v,
        default: function() {
          return STATUS_ENUM[0];
        }
      },
      type: {
        //alias: "",
        type: String,
        select: null,
        required: true,
        index: false,
        unique: false,
        get: v => v, 
        set: v => v,
        default: function() {
          return TYPE_ENUM[0];
        }
      },
      data: {
        alias: "payload",
        type: Object,
        select: null,
        required: false,
        index: false,
        unique: false,
        validate: {
          validator: function(value) {
            return true;
          },
          message: props => props.value+" is not a valid!"
        },
        trim: true,
        get: v => v, 
        set: v => v,
        default: function () {
          return null;
        }
      },
      userId: {
        type: ObjectId,
        select: null,
        required: true,
        index: false,
        unique: false,
        ref: 'User',
        get: v => v,
        set: v => v,
      }
    },
    { // options
      timestamps: true,
      collection: 'note'
    }
  );
  
  // noteSchema.virtual("_virtualKey")
  //   .get(function() {
  //     return `${this.attr} (${this.attr})`;
  //   });
  
  // indexes...
  // noteSchema.index( {attr: 1, attr: 1}, 
  //   {
  //     unique: true, 
  //     name: "constraint_A_B"
  //   });
  
  // instance methods...
  noteSchema.methods = {
  
  }
  
  // static methods...
  noteSchema.statics = {
  
  }
  
  // triggers...
    noteSchema.pre(['updateOne', 'findOneAndUpdate'], async function(next) {
      let docToUpdate  = await this.model.findOne(this.getQuery());
      let intoToUpdate = this.getUpdate();
  
      // code...
  
      this.setUpdate(intoToUpdate);
      next();
    });
  
    noteSchema.pre('save', function(next) {
      // code...
  
      next();
    });
    noteSchema.post('save', function(  ) {
      // code...
    });
  
  // exports => 
    const NoteModel = mongoose.model('Note', noteSchema);
    module.exports = NoteModel;
  