0.0.2 • Published 7 years ago

mongoose-plugin-compose v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

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