all files / lib/waterline/collection/ index.js

100% Statements 16/16
75% Branches 3/4
100% Functions 1/1
100% Lines 16/16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57                                                  266×     266×     266×     266×     266×     266×   266×          
/**
 * Dependencies
 */
 
var _ = require('lodash');
var extend = require('../utils/extend');
var inherits = require('util').inherits;
 
// Various Pieces
var Core = require('../core');
var Query = require('../query');
 
/**
 * Collection
 *
 * A prototype for managing a collection of database
 * records.
 *
 * This file is the prototype for collections defined using Waterline.
 * It contains the entry point for all ORM methods (e.g. User.find())
 *
 * Methods in this file defer to the adapter for their true implementation:
 * the implementation here just validates and normalizes the parameters.
 *
 * @param {Object} waterline, reference to parent
 * @param {Object} options
 * @param {Function} callback
 */
 
var Collection = module.exports = function(waterline, connections, cb) {
 
  var self = this;
 
  // Set the named connections
  this.connections = connections || {};
 
  // Cache reference to the parent
  this.waterline = waterline;
 
  // Default Attributes
  this.attributes = this.attributes || {};
 
  // Instantiate Base Collection
  Core.call(this);
 
  // Instantiate Query Language
  Query.call(this);
 
  return this;
};
 
inherits(Collection, Core);
inherits(Collection, Query);
 
// Make Extendable
Collection.extend = extend;