BVB Source Codes

waterline Show raw-example.js Source code

Return Download waterline: download raw-example.js Source code - Download waterline Source code - Type:.js
  1. #!/usr/bin/env node
  2.  
  3.  
  4. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5. // `raw-example.js`
  6. //
  7. // This is an example demonstrating how to use Waterline
  8. // from a vanilla Node.js script.
  9. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  10.  
  11.  
  12. // Import dependencies
  13. var setupWaterline = require('./bootstrap');
  14. var SailsDiskAdapter = require('sails-disk');
  15.  
  16.  
  17. // Set up Waterline.
  18. setupWaterline({
  19.  
  20.  
  21.   adapters: {
  22.  
  23.     'sails-disk': SailsDiskAdapter
  24.  
  25.   },
  26.  
  27.  
  28.   datastores: {
  29.  
  30.     myDb: {
  31.       adapter: 'sails-disk'
  32.     }
  33.  
  34.   },
  35.  
  36.  
  37.   models: {
  38.  
  39.     user: {
  40.       connection: 'myDb',//<< the datastore this model should use
  41.       attributes: {}
  42.     }
  43.  
  44.   }
  45.  
  46.  
  47. }, function waterlineReady (err, ontology) {
  48.   if (err) {
  49.     console.error('Could not set up Waterline: '+err.stack);
  50.     return;
  51.   }//--鈥
  52.  
  53.  
  54.  
  55.   // Our model definitions
  56.   console.log(
  57.     '\n'+
  58.     '\n'+
  59.     '==========================================================================\n'+
  60.     '鈥 Model definitions:                                                     鈥n'+
  61.     '==========================================================================\n',
  62.     ontology.models
  63.   );
  64.   //
  65.   // e.g.
  66.   // models.user.find().exec(...)
  67.   // models.user.find().exec(...)
  68.  
  69.  
  70.   // Our datastore definitions
  71.   console.log(
  72.     '\n'+
  73.     '\n'+
  74.     '==========================================================================\n'+
  75.     '鈥 Datastore definitions:                                                 鈥n'+
  76.     '==========================================================================\n',
  77.     ontology.datastores
  78.   );
  79.   //
  80.   // e.g.
  81.   // datastores.myDb.config;
  82.  
  83.  
  84.   console.log();
  85.   console.log();
  86.   console.log('--');
  87.   console.log('Waterline is ready.');
  88.   console.log('(this is where you could write come code)');
  89.  
  90. });
  91.  
  92.  
downloadraw-example.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
GoSublime - A Golang plugin collection for SublimeText **3**, ... 2017-02-19
awesome-emacs - A community driven list of useful Emacs packages, ... 2017-02-19
RKNotificationHub - Make any UIView a full fledged notification center 2017-02-19
vimr - Project VimR - Refined Neovim experience for macOS... 2017-02-19
vue-admin - Vue Admin Panel Framework, Powered by Vue 2.0 and ... 2017-02-19
dev-setup - Mac OS X development environment setup: Easy-to-un... 2017-02-19
CMPopTipView - Custom UIView for iOS that pops up an animated "bu... 2017-02-19
git-recipes - Git for recipes in Chinese. The high quality of Gi... 2017-02-19
CLNDR - 2017-02-19
OptiKey - OptiKey - Full computer control and speech with yo... 2017-02-19

 Back to top