models.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. var {Store, 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. var mysqlConnectionProperties = "?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useServerPrepStmts&enableQueryTimeouts=false&useUnbufferedIO=false&useReadAheadInput=false&maintainTimeStats=false&cacheRSMetadata=true";
  8. return Store.initConnectionPool({
  9. "url": "jdbc:mysql://" + dbHost + "/hello_world" + mysqlConnectionProperties,
  10. "driver": "com.mysql.jdbc.Driver",
  11. "user": "benchmarkdbuser",
  12. "password": "benchmarkdbpass",
  13. "minimumIdle": 10,
  14. "maximumPoolSize": 30
  15. });
  16. });
  17. var store = exports.store = new Store(connectionPool);
  18. var queryCache = module.singleton("queryCache", function() {
  19. return new Cache(10000);
  20. });
  21. store.setQueryCache(queryCache);
  22. // define entities in DB
  23. exports.World = store.defineEntity('World', {
  24. table: 'World',
  25. id: {
  26. column: 'id'
  27. },
  28. properties: {
  29. randomNumber: 'integer'
  30. }
  31. });
  32. var Fortune = exports.Fortune = store.defineEntity('Fortune', {
  33. table: 'Fortune',
  34. properties: {
  35. message: 'string'
  36. }
  37. });
  38. Fortune.sort = function(a, b) {
  39. return (a.message < b.message) ? -1 : (a.message > b.message) ? 1 : 0;
  40. };