{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback-connector-db2/issues/3","repository_url":"https://api.github.com/repos/strongloop/loopback-connector-db2","labels_url":"https://api.github.com/repos/strongloop/loopback-connector-db2/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback-connector-db2/issues/3/comments","events_url":"https://api.github.com/repos/strongloop/loopback-connector-db2/issues/3/events","html_url":"https://github.com/strongloop/loopback-connector-db2/issues/3","id":128202728,"number":3,"title":"Offset and skip with SQL instead of JavaScript split","user":{"login":"jcurlier","id":2846867,"avatar_url":"https://avatars.githubusercontent.com/u/2846867?v=3","gravatar_id":"","url":"https://api.github.com/users/jcurlier","html_url":"https://github.com/jcurlier","followers_url":"https://api.github.com/users/jcurlier/followers","following_url":"https://api.github.com/users/jcurlier/following{/other_user}","gists_url":"https://api.github.com/users/jcurlier/gists{/gist_id}","starred_url":"https://api.github.com/users/jcurlier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcurlier/subscriptions","organizations_url":"https://api.github.com/users/jcurlier/orgs","repos_url":"https://api.github.com/users/jcurlier/repos","events_url":"https://api.github.com/users/jcurlier/events{/privacy}","received_events_url":"https://api.github.com/users/jcurlier/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"qpresley","id":15216139,"avatar_url":"https://avatars.githubusercontent.com/u/15216139?v=3","gravatar_id":"","url":"https://api.github.com/users/qpresley","html_url":"https://github.com/qpresley","followers_url":"https://api.github.com/users/qpresley/followers","following_url":"https://api.github.com/users/qpresley/following{/other_user}","gists_url":"https://api.github.com/users/qpresley/gists{/gist_id}","starred_url":"https://api.github.com/users/qpresley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qpresley/subscriptions","organizations_url":"https://api.github.com/users/qpresley/orgs","repos_url":"https://api.github.com/users/qpresley/repos","events_url":"https://api.github.com/users/qpresley/events{/privacy}","received_events_url":"https://api.github.com/users/qpresley/received_events","type":"User","site_admin":false},"assignees":[{"login":"qpresley","id":15216139,"avatar_url":"https://avatars.githubusercontent.com/u/15216139?v=3","gravatar_id":"","url":"https://api.github.com/users/qpresley","html_url":"https://github.com/qpresley","followers_url":"https://api.github.com/users/qpresley/followers","following_url":"https://api.github.com/users/qpresley/following{/other_user}","gists_url":"https://api.github.com/users/qpresley/gists{/gist_id}","starred_url":"https://api.github.com/users/qpresley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qpresley/subscriptions","organizations_url":"https://api.github.com/users/qpresley/orgs","repos_url":"https://api.github.com/users/qpresley/repos","events_url":"https://api.github.com/users/qpresley/events{/privacy}","received_events_url":"https://api.github.com/users/qpresley/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2016-01-22T17:21:06Z","updated_at":"2017-02-16T17:56:52Z","closed_at":null,"body":"It seems we are using a JavaScript split to keep only the records from a given row to a given row.\n\n`if (offset || limit) {\n      data = data.slice(offset, offset + limit);\n    }\n`\n\nShould we do this as part of the SQL query to avoid transporting the data and parsing it? the Oracle driver is doing it this way. For example:\n\ndb2.prototype.buildColumnNames = function(model, filter) {\n  var columnNames = this.invokeSuper('buildColumnNames', model, filter);\n  if (filter.limit || filter.offset || filter.skip) {\n    var orderBy = this.buildOrderBy(model, filter.order);\n    columnNames += ',ROW_NUMBER() OVER' + ' (' + orderBy + ') rownum';\n  }\n  return columnNames;\n};\n\ndb2.prototype.applyPagination = function(model, stmt, filter) {\n  var offset = filter.offset || filter.skip || 0;\n\n  var paginatedSQL = 'SELECT \\* FROM ( ' + stmt.sql + ' ) WHERE rownum > ' + offset;\n\n  if (filter.limit !== -1) {\n    paginatedSQL += ' AND rownum <= ' + (offset + filter.limit);\n  }\n\n  stmt.sql = paginatedSQL + ' ';\n\n  return stmt;\n};\n"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback-connector-db2/issues/comments/280407509","html_url":"https://github.com/strongloop/loopback-connector-db2/issues/3#issuecomment-280407509","issue_url":"https://api.github.com/repos/strongloop/loopback-connector-db2/issues/3","id":280407509,"user":{"login":"jcurlier","id":2846867,"avatar_url":"https://avatars.githubusercontent.com/u/2846867?v=3","gravatar_id":"","url":"https://api.github.com/users/jcurlier","html_url":"https://github.com/jcurlier","followers_url":"https://api.github.com/users/jcurlier/followers","following_url":"https://api.github.com/users/jcurlier/following{/other_user}","gists_url":"https://api.github.com/users/jcurlier/gists{/gist_id}","starred_url":"https://api.github.com/users/jcurlier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcurlier/subscriptions","organizations_url":"https://api.github.com/users/jcurlier/orgs","repos_url":"https://api.github.com/users/jcurlier/repos","events_url":"https://api.github.com/users/jcurlier/events{/privacy}","received_events_url":"https://api.github.com/users/jcurlier/received_events","type":"User","site_admin":false},"created_at":"2017-02-16T17:56:52Z","updated_at":"2017-02-16T17:56:52Z","body":"Sure - thanks"}}
{"actor":{"display_login":"jcurlier"}}