How to use the ormnomnom/fields.AutoField 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
var needsAutoField = true,
      fields = require('ormnomnom/fields');

  var meta = new ModelMeta(name, this);
  this._meta = meta;

  Object.keys(options).forEach(function(key) {
    meta.addField(key, options[key]);
    if(options[key].isPrimaryKey()) {
      needsAutoField = false;
      this.setPrimaryKey(options[key]);
    }
  }.bind(this));

  if(needsAutoField) {
    var autoField = fields.AutoField();
    meta.addField('id', autoField);
    this.setPrimaryKey(autoField);
  }
};

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