BVB Source Codes

waterline Show collection.js Source code

Return Download waterline: download collection.js Source code - Download waterline Source code - Type:.js
  1. /**
  2.  * Module dependencies
  3.  */
  4.  
  5. var _ = require('@sailshq/lodash');
  6. var extend = require('./utils/system/extend');
  7. var LifecycleCallbackBuilder = require('./utils/system/lifecycle-callback-builder');
  8. var TransformerBuilder = require('./utils/system/transformer-builder');
  9. var hasSchemaCheck = require('./utils/system/has-schema-check');
  10.  
  11. /**
  12.  * Collection
  13.  *
  14.  * A prototype for managing a collection of database records.
  15.  *
  16.  * This file is the prototype for collections defined using Waterline.
  17.  * It contains the entry point for all ORM methods (e.g. User.find())
  18.  *
  19.  * Methods in this file defer to the adapter for their true implementation:
  20.  * the implementation here just validates and normalizes the parameters.
  21.  *
  22.  * @param {Dictionay} waterline, reference to parent
  23.  * @param {Dictionay} options
  24.  * @param {Function} callback
  25.  */
  26.  
  27. var Collection = module.exports = function(waterline, datastore) {
  28.  
  29.   // Set the named datastores
  30.   this._adapter = datastore.adapter;
  31.  
  32.   // Cache reference to the parent
  33.   this.waterline = waterline;
  34.  
  35.   // Default Attributes
  36.   this.attributes = this.attributes || {};
  37.  
  38.   // Set Defaults
  39.   this.adapter = this.adapter || {};
  40.  
  41.   // Build lifecycle callbacks
  42.   this._callbacks = LifecycleCallbackBuilder(this);
  43.  
  44.   // Check if the hasSchema flag is set
  45.   this.hasSchema = hasSchemaCheck(this);
  46.  
  47.   // Build Data Transformer
  48.   this._transformer = new TransformerBuilder(this.schema);
  49.  
  50.   return this;
  51. };
  52.  
  53.  
  54. // Extend the Collection's prototype with the Query functions. This allows for
  55. // the use of Foo.find(), etc.
  56. _.extend(
  57.   Collection.prototype,
  58.   require('./methods')
  59. );
  60.  
  61.  
  62. // Make Extendable
  63. Collection.extend = extend;
  64.  
downloadcollection.js Source code - Download waterline Source code
Related Source Codes/Software:
notepad-plus-plus - Notepad++ official repository h... 2017-01-10
che - Eclipse Che: Next-generation Eclipse IDE. Open sou... 2017-01-10
Gource - oftware version control visualization ... 2017-01-10
FDFullscreenPopGesture - A UINavigationController's category to enable full... 2017-01-10
node-style-guide - A guide for styling your node.js / JavaScript code... 2017-01-09
Workerman - An asynchronous event driven PHP framework for eas... 2017-01-10
structor - An advanced visual editor for React components ... 2017-01-10
golearn - Machine Learning for Go 2017-01-10
poisontap - Exploits locked/password protected computers over ... 2017-01-10
kcptun - A Simple UDP Tunnel Based On KCP 2017-01-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top