lib/model.js
function Model (name, schema, options) {
  if (typeof(name) != "string") throw "model name must be provided and a string";
  if (arguments.length==1) { options = {}; schema = {} };
  if (arguments.length==2) { options = schema; schema = {} };

  var self = function Document(raw) { return document.Document.call(this, self, raw) }; // Call the Document builder
  _.extend(self, Model.prototype); // Ugly but works - we need to return a function but still inherit prototype
  var emitter = new events.EventEmitter();
  emitter.setMaxListeners(0);
  for (var prop in emitter) self[prop] = emitter[prop];

  self.modelName = name;
  self.schema = schemas.normalize(Object.assign({}, schema)); // Normalize to allow for short-hands
  self.filename = path.normalize(options.filename || path.join(Model.dbPath || ".", name+".db"));
  self.options  = _.extend({}, Model.defaults, options);

  // Indexed by field name, dot notation can be used
  // _id is always indexed and since _ids are generated randomly the underlying
  // binary is always well-balanced
  self.indexes = {};
  self.indexes._id = new Index({ fieldName: '_id', unique: true });
  schemas.indexes(schema).forEach(function(idx) { self.ensureIndex(idx) });

  // Concurrency control for 1) index building and 2) pulling objects from LevelUP
  self._pipe = new bagpipe(1);
  self._pipe.pause();
  self._retrQueue = new bagpipe(LEVELUP_RETR_CONCURRENCY);
  self._retrQueue._locked = {}; self._retrQueue._locks = {}; // Hide those in ._retrQueue
  self._methods = {};

  if (self.options.autoLoad) self.initStore();

  return self;
}
function Model (name, schema, options) {
  if (typeof(name) != "string") throw "model name must be provided and a string";
  if (arguments.length==1) { options = {}; schema = {} };
  if (arguments.length==2) { options = schema; schema = {} };

  var self = function Document(raw) { return document.Document.call(this, self, raw) }; // Call the Document builder
  _.extend(self, Model.prototype); // Ugly but works - we need to return a function but still inherit prototype
  var emitter = new events.EventEmitter();
  emitter.setMaxListeners(0);
  for (var prop in emitter) self[prop] = emitter[prop];

  self.modelName = name;
  self.schema = schemas.normalize(Object.assign({}, schema)); // Normalize to allow for short-hands
  self.filename = path.normalize(options.filename || path.join(Model.dbPath || ".", name+".db"));
  self.options  = _.extend({}, Model.defaults, options);

  // Indexed by field name, dot notation can be used
  // _id is always indexed and since _ids are generated randomly the underlying
  // binary is always well-balanced
  self.indexes = {};
  self.indexes._id = new Index({ fieldName: '_id', unique: true });
  schemas.indexes(schema).forEach(function(idx) { self.ensureIndex(idx) });

  // Concurrency control for 1) index building and 2) pulling objects from LevelUP
  self._pipe = new bagpipe(1);
  self._pipe.pause();
  self._retrQueue = new bagpipe(LEVELUP_RETR_CONCURRENCY);
  self._retrQueue._locked = {}; self._retrQueue._locks = {}; // Hide those in ._retrQueue
  self._methods = {};

  if (self.options.autoLoad) self.initStore();

  return self;
}
function Model ( name , schema , options ) { if ( typeof ( name ) != "string" ) throw "model name must be provided and a string" ; if ( arguments . length == 1 ) { options = { } ; schema = { } } ; if ( arguments . length == 2 ) { options = schema ; schema = { } } ; var self = function Document ( raw ) { return document . Document . call ( this , self , raw ) } ; // Call the Document builder _ . extend ( self , Model . prototype ) ; // Ugly but works - we need to return a function but still inherit prototype var emitter = new events . EventEmitter ( ) ; emitter . setMaxListeners ( 0 ) ; for ( var prop in emitter ) self [ prop ] = emitter [ prop ] ; self . modelName = name ; self . schema = schemas . normalize ( Object . assign ( { } , schema ) ) ; // Normalize to allow for short-hands self . filename = path . normalize ( options . filename || path . join ( Model . dbPath || "." , name + ".db" ) ) ; self . options = _ . extend ( { } , Model . defaults , options ) ; // Indexed by field name, dot notation can be used // _id is always indexed and since _ids are generated randomly the underlying // binary is always well-balanced self . indexes = { } ; self . indexes . _id = new Index ( { fieldName : '_id' , unique : true } ) ; schemas . indexes ( schema ) . forEach ( function ( idx ) { self . ensureIndex ( idx ) } ) ; // Concurrency control for 1) index building and 2) pulling objects from LevelUP self . _pipe = new bagpipe ( 1 ) ; self . _pipe . pause ( ) ; self . _retrQueue = new bagpipe ( LEVELUP_RETR_CONCURRENCY ) ; self . _retrQueue . _locked = { } ; self . _retrQueue . _locks = { } ; // Hide those in ._retrQueue self . _methods = { } ; if ( self . options . autoLoad ) self . initStore ( ) ; return self ; }
We'll use that on a bagpipe instance regulating findById 
Create a new model
We ll use that on a bagpipe instance regulating findById Create a new model