models.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. 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 new ConnectionPool({
  9. "url": "jdbc:mysql://" + dbHost + "/hello_world" + mysqlConnectionProperties,
  10. "driver": "com.mysql.jdbc.Driver",
  11. "username": "benchmarkdbuser",
  12. "password": "benchmarkdbpass"
  13. });
  14. });
  15. var store = exports.store = new Store(connectionPool);
  16. var queryCache = module.singleton("queryCache", function() {
  17. return new Cache(10000);
  18. });
  19. store.setQueryCache(queryCache);
  20. // define entities in DB
  21. exports.World = store.defineEntity('World', {
  22. table: 'World',
  23. id: {
  24. column: 'id'
  25. },
  26. properties: {
  27. randomNumber: 'integer'
  28. }
  29. });
  30. var Fortune = exports.Fortune = store.defineEntity('Fortune', {
  31. table: 'Fortune',
  32. properties: {
  33. message: 'string'
  34. }
  35. });
  36. Fortune.sort = function(a, b) {
  37. return (a.message < b.message) ? -1 : (a.message > b.message) ? 1 : 0;
  38. };