Advertisement
Guest User

Untitled

a guest
Feb 26th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. var underscore = require('underscore');
  2. var mysql = require('mysql');
  3. var baseConfig = require('../config/base');
  4.  
  5. var autoload = require('../autoload');
  6.  
  7. var core = autoload.load(baseConfig.dirs.core);
  8.  
  9. module.exports = {
  10. name: 'model',
  11. database: null,
  12. error: null,
  13.  
  14. construct: function(host, user, password, database, res) {
  15. var connection = mysql.createConnection({
  16. host: host,
  17. user: user,
  18. password: password,
  19. database: database
  20. });
  21.  
  22. connection.connect(function(error) {
  23. if(error) this.error = error;
  24. });
  25.  
  26. this.database = connection;
  27. if(this.error) return false;
  28. },
  29.  
  30. extend: function(child) {
  31. return underscore.extend(this, child);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement