How to use the ormnomnom/model/manager.Manager function in ormnomnom

To help you get started, we’ve selected a few ormnomnom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chrisdickinson / ormnomnom / lib / model / base.js View on Github external
Model.define = function(name, opts) {
  var ModelInstance = function(data) {
    ModelInstance._meta.decodeData(this, data);
  };

  ModelInstance.prototype = new Model(name, opts);
  ModelInstance.objects = new Manager(ModelInstance);
  ModelInstance.meta = function(opts) {
    Object.keys(opts).forEach(function(key) {
      this[key] = opts[key];
    }.bind(this._meta));
  };
  ModelInstance._meta = ModelInstance.prototype._meta;

  Model.events.emit('model', ModelInstance); 
  Model.events.emit('model:'+ModelInstance._meta.model_name, ModelInstance); 
  return ModelInstance;
};

ormnomnom

a lightweight orm to silence the orm-y beast

MIT
Latest version published 2 years ago

Package Health Score

54 / 100
Full package analysis