BVB Source Codes

waterline Show bootstrap.js Source code

Return Download waterline: download bootstrap.js Source code - Download waterline Source code - Type:.js
  1. /**
  2.  * Module dependencies
  3.  */
  4.  
  5. var _ = require('@sailshq/lodash');
  6. var Waterline = require('../../lib/waterline'); //<< replace that with `require('waterline')`
  7.  
  8.  
  9.  
  10. /**
  11.  * Set up Waterline with the specified
  12.  * models, datastores, and adapters.
  13.  *
  14.  * > This is just an example of a little utility
  15.  * > that makes Waterline easier to work with,
  16.  * > for convenience.
  17.  *
  18.  * @optional {Dictionary} adapters
  19.  * @optional {Dictionary} datastores
  20.  * @optional {Dictionary} models
  21.  *
  22.  * @callback
  23.  *   @param {Error?} err
  24.  *   @param {Dictionary} ontology
  25.  *     @property {Dictionary} models
  26.  *     @property {Dictionary} datastores
  27.  */
  28.  
  29. module.exports = function bootstrap (options, done) {
  30.  
  31.   var adapterDefs = options.adapters || {};
  32.   var datastores = options.datastores || {};
  33.   var models = options.models || {};
  34.  
  35.  
  36.  
  37.   // Assign an `identity` to each of our adapter definitions.
  38.   _.each(adapterDefs, function (def, key) {
  39.     def.identity = def.identity || key;
  40.   });
  41.  
  42.  
  43.   // Assign an `identity` and call `Waterline.Model.extend()`
  44.   // on each of our model definitions.
  45.   var extendedModelDefs = _.reduce(models, function (memo, def, key) {
  46.     def.identity = def.identity || key;
  47.     memo.push(Waterline.Model.extend(def));
  48.     return memo;
  49.   }, []);
  50.  
  51.  
  52.   // Construct a Waterline ORM instance.
  53.   var orm = new Waterline();
  54.  
  55.  
  56.   // Load the  already-extended Waterline collections.
  57.   extendedModelDefs.forEach(function (extendedModelDef) {
  58.     orm.registerModel(extendedModelDef);
  59.   });
  60.  
  61.  
  62.   // Initialize this Waterline ORM instance.
  63.   // (and tell it about our adapters)
  64.   orm.initialize({
  65.     adapters: adapterDefs,
  66.     connections: datastores,
  67.   }, function (err, rawResult){
  68.     if (err) { return done(err); }
  69.  
  70.     // Send back the ORM metadata.
  71.     // (we call this the "ontology")
  72.     return done(undefined, {
  73.       models: rawResult.collections,
  74.       datastores: rawResult.connections,
  75.     });
  76.  
  77.   });//</orm.initialize()>
  78.  
  79. };
  80.  
  81.  
downloadbootstrap.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