I want to create a custom set of attributes and lifecycle methods that are shared between all my Sails.js models.
Sails.js automatically creates and registers the model objects by calling the Waterline.Collection.extend()
method and providing the model definition found inside the /api/models
directory.
What would be the best way to extend my model definition from a parent? I already tried using _.extend(sails.config.model.parentModel, childModel)
but sadly the sails
object is not exposed globally (since this is done after loading the orm hook). I could also simply require()
the base model in all my models and extend it.
What would be a clean approach that goes well with Sails?
See Question&Answers more detail:os