mongoose-plugin-compose

    0.0.2 • Public • Published

    Build Status Coverage Status

    Mongoose Plugin Compose

    Defer commitment to the ORM. Separate your domain models from your persistence models.

     
    const compose = require('mongoose-plugin-compose').default;
     
    class Animal {
      speak(){
        console.log(this.name)
      }
    }
     
    const Cat = mongoose.model('Cat', new mongoose.Schema({
      name: String
    }));
     
    Cat.schema.plugin(compose(Animal));
     
    const cat = new Cat({ name: 'fido'});
     
    cat.speak(); // fido
     

    Keywords

    none

    Install

    npm i mongoose-plugin-compose

    DownloadsWeekly Downloads

    5

    Version

    0.0.2

    License

    MIT

    Last publish

    Collaborators

    • avatar