models.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. var {Store, ConnectionPool, Cache} = require('ringo-sqlstore');
  2. // DO NOT TOUCH THE FOLLOWING LINE.
  3. // THIS VARIABLE IS REGEX REPLACED BY setup.py
  4. var dbHost = '172.16.98.98';
  5. // create and configure store
  6. var connectionPool = module.singleton("connectionPool", function() {
  7. return new ConnectionPool({
  8. "url": "jdbc:mysql://" + dbHost + "/hello_world",
  9. "driver": "com.mysql.jdbc.Driver",
  10. "username": "benchmarkdbuser",
  11. "password": "benchmarkdbpass"
  12. });
  13. });
  14. var store = exports.store = new Store(connectionPool);
  15. var queryCache = module.singleton("queryCache", function() {
  16. return new Cache(10000);
  17. });
  18. store.setQueryCache(queryCache);
  19. // define entities in DB
  20. exports.World = store.defineEntity('World', {
  21. table: 'World',
  22. id: {
  23. column: 'id'
  24. },
  25. properties: {
  26. randomNumber: 'integer'
  27. }
  28. });
  29. var Fortune = exports.Fortune = store.defineEntity('Fortune', {
  30. table: 'Fortune',
  31. properties: {
  32. message: 'string'
  33. }
  34. });
  35. Fortune.sort = function(a, b) {
  36. return (a.message < b.message) ? -1 : (a.message > b.message) ? 1 : 0;
  37. };