Skip to content

Inherit the prototype methods from a constructor or object onto mongoose instances.

License

Notifications You must be signed in to change notification settings

blugavere/mongoose-plugin-compose

Repository files navigation

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

About

Inherit the prototype methods from a constructor or object onto mongoose instances.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published