{"action":"created","comment":{"url":"https://api.github.com/repos/Kinvey/js-sdk/pulls/comments/174749389","pull_request_review_id":104115438,"id":174749389,"diff_hunk":"@@ -0,0 +1,99 @@\n+import isArray from 'lodash/isArray';\n+import { format } from 'url';\n+import { Query } from '../query';\n+import { KinveyRequest, RequestMethod, AuthType } from '../request';\n+import { Client } from '../client';\n+import { repositoryProvider } from './repositories';\n+import { stripTagFromCollectionName, generateEntityId } from './utils';\n+\n+const QUERY_CACHE_COLLECTION_NAME = '_QueryCache';\n+\n+export function deltaSet(collectionNameWithTag, query, options) {\n+  const collectionName = stripTagFromCollectionName(collectionNameWithTag);\n+  const serializedQuery = query ? JSON.stringify(query.toQueryString()) : '';\n+\n+  return repositoryProvider.getOfflineRepository()\n+    .then((offlineRepo) => {\n+      const queryCacheQuery = new Query()\n+        .equalTo('collectionName', collectionName)\n+        .and()\n+        .equalTo('query', serializedQuery);\n+      return offlineRepo.read(QUERY_CACHE_COLLECTION_NAME, queryCacheQuery)\n+        .then((deltaSetQueryDocs = []) => {\n+          if (deltaSetQueryDocs.length > 0) {\n+            return deltaSetQueryDocs[0];\n+          }\n+\n+          return {\n+            _id: generateEntityId(),\n+            collectionName: collectionName,\n+            query: serializedQuery\n+          };\n+        })\n+        .then((deltaSetQueryDoc) => {\n+          const client = Client.sharedInstance();\n+          let url = format({\n+            protocol: client.apiProtocol,\n+            host: client.apiHost,\n+            pathname: `/appdata/${client.appKey}/${collectionName}`\n+          });\n+\n+          if (deltaSetQueryDoc.lastRequest) {\n+            url = format({\n+              protocol: client.apiProtocol,\n+              host: client.apiHost,\n+              pathname: `/appdata/${client.appKey}/${collectionName}/_deltaset`,\n+              query: { since: deltaSetQueryDoc.lastRequest }\n+            });\n+          }\n+\n+          const request = new KinveyRequest({\n+            authType: AuthType.Session,\n+            method: RequestMethod.GET,\n+            url,\n+            query,\n+            timeout: options.timeout,\n+            followRedirect: options.followRedirect,\n+            cache: options.cache,\n+            properties: options.properties,\n+            skipBL: options.skipBL,\n+            trace: options.trace,\n+            client\n+          });\n+          return request.execute()\n+            .then((response) => {\n+              deltaSetQueryDoc.lastRequest = response.headers.get('X-Kinvey-Request-Start');","path":"src/core/datastore/deltaset.js","position":65,"original_position":65,"commit_id":"4df7ded2bf973d93bd6b5596b9f86761c9a6c1b4","original_commit_id":"4df7ded2bf973d93bd6b5596b9f86761c9a6c1b4","user":{"login":"georgiwe","id":5816340,"avatar_url":"https://avatars2.githubusercontent.com/u/5816340?v=4","gravatar_id":"","url":"https://api.github.com/users/georgiwe","html_url":"https://github.com/georgiwe","followers_url":"https://api.github.com/users/georgiwe/followers","following_url":"https://api.github.com/users/georgiwe/following{/other_user}","gists_url":"https://api.github.com/users/georgiwe/gists{/gist_id}","starred_url":"https://api.github.com/users/georgiwe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgiwe/subscriptions","organizations_url":"https://api.github.com/users/georgiwe/orgs","repos_url":"https://api.github.com/users/georgiwe/repos","events_url":"https://api.github.com/users/georgiwe/events{/privacy}","received_events_url":"https://api.github.com/users/georgiwe/received_events","type":"User","site_admin":false},"body":"Maybe a constant for the header name?","created_at":"2018-03-15T11:17:43Z","updated_at":"2018-03-15T11:18:19Z","html_url":"https://github.com/Kinvey/js-sdk/pull/270#discussion_r174749389","pull_request_url":"https://api.github.com/repos/Kinvey/js-sdk/pulls/270","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Kinvey/js-sdk/pulls/comments/174749389"},"html":{"href":"https://github.com/Kinvey/js-sdk/pull/270#discussion_r174749389"},"pull_request":{"href":"https://api.github.com/repos/Kinvey/js-sdk/pulls/270"}}},"pull_request":{"url":"https://api.github.com/repos/Kinvey/js-sdk/pulls/270","id":175012370,"html_url":"https://github.com/Kinvey/js-sdk/pull/270","diff_url":"https://github.com/Kinvey/js-sdk/pull/270.diff","patch_url":"https://github.com/Kinvey/js-sdk/pull/270.patch","issue_url":"https://api.github.com/repos/Kinvey/js-sdk/issues/270","number":270,"state":"open","locked":false,"title":"MLIBZ-2316: Server Side Delta Set","user":{"login":"thomasconner","id":950052,"avatar_url":"https://avatars1.githubusercontent.com/u/950052?v=4","gravatar_id":"","url":"https://api.github.com/users/thomasconner","html_url":"https://github.com/thomasconner","followers_url":"https://api.github.com/users/thomasconner/followers","following_url":"https://api.github.com/users/thomasconner/following{/other_user}","gists_url":"https://api.github.com/users/thomasconner/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasconner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasconner/subscriptions","organizations_url":"https://api.github.com/users/thomasconner/orgs","repos_url":"https://api.github.com/users/thomasconner/repos","events_url":"https://api.github.com/users/thomasconner/events{/privacy}","received_events_url":"https://api.github.com/users/thomasconner/received_events","type":"User","site_admin":false},"body":"#### Description\r\nAdd support for server side delta set.\r\n\r\n#### Changes\r\n- Rename `deltaFetch.js` to `deltaSet.js` and move it to under `src/core/datastore`. This no longer extends the `Request` class.\r\n- `deltaSet.js` add support for sending delta set requests and clearing the query cache.\r\n- Rename `option.useDeltaFetch` to `option.useDeltaSet` on datastore instances. @tejasranade says this does not need to be backwards compatible.\r\n\r\n#### Test\r\n- Added tests to `cachestore.spec.js` for sending a delta set request with and without a tagged collection.","created_at":"2018-03-14T16:28:12Z","updated_at":"2018-03-15T11:18:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dbf246b6be52a051d80055dd525584f31b3d61a1","assignee":{"login":"thomasconner","id":950052,"avatar_url":"https://avatars1.githubusercontent.com/u/950052?v=4","gravatar_id":"","url":"https://api.github.com/users/thomasconner","html_url":"https://github.com/thomasconner","followers_url":"https://api.github.com/users/thomasconner/followers","following_url":"https://api.github.com/users/thomasconner/following{/other_user}","gists_url":"https://api.github.com/users/thomasconner/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasconner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasconner/subscriptions","organizations_url":"https://api.github.com/users/thomasconner/orgs","repos_url":"https://api.github.com/users/thomasconner/repos","events_url":"https://api.github.com/users/thomasconner/events{/privacy}","received_events_url":"https://api.github.com/users/thomasconner/received_events","type":"User","site_admin":false},"assignees":[{"login":"thomasconner","id":950052,"avatar_url":"https://avatars1.githubusercontent.com/u/950052?v=4","gravatar_id":"","url":"https://api.github.com/users/thomasconner","html_url":"https://github.com/thomasconner","followers_url":"https://api.github.com/users/thomasconner/followers","following_url":"https://api.github.com/users/thomasconner/following{/other_user}","gists_url":"https://api.github.com/users/thomasconner/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasconner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasconner/subscriptions","organizations_url":"https://api.github.com/users/thomasconner/orgs","repos_url":"https://api.github.com/users/thomasconner/repos","events_url":"https://api.github.com/users/thomasconner/events{/privacy}","received_events_url":"https://api.github.com/users/thomasconner/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Kinvey/js-sdk/pulls/270/commits","review_comments_url":"https://api.github.com/repos/Kinvey/js-sdk/pulls/270/comments","review_comment_url":"https://api.github.com/repos/Kinvey/js-sdk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Kinvey/js-sdk/issues/270/comments","statuses_url":"https://api.github.com/repos/Kinvey/js-sdk/statuses/4df7ded2bf973d93bd6b5596b9f86761c9a6c1b4","head":{"label":"Kinvey:MLIBZ-2316_server_side_delta_set","ref":"MLIBZ-2316_server_side_delta_set","sha":"4df7ded2bf973d93bd6b5596b9f86761c9a6c1b4","user":{"login":"Kinvey","id":1276480,"avatar_url":"https://avatars2.githubusercontent.com/u/1276480?v=4","gravatar_id":"","url":"https://api.github.com/users/Kinvey","html_url":"https://github.com/Kinvey","followers_url":"https://api.github.com/users/Kinvey/followers","following_url":"https://api.github.com/users/Kinvey/following{/other_user}","gists_url":"https://api.github.com/users/Kinvey/gists{/gist_id}","starred_url":"https://api.github.com/users/Kinvey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kinvey/subscriptions","organizations_url":"https://api.github.com/users/Kinvey/orgs","repos_url":"https://api.github.com/users/Kinvey/repos","events_url":"https://api.github.com/users/Kinvey/events{/privacy}","received_events_url":"https://api.github.com/users/Kinvey/received_events","type":"Organization","site_admin":false},"repo":{"id":30971013,"name":"js-sdk","full_name":"Kinvey/js-sdk","owner":{"login":"Kinvey","id":1276480,"avatar_url":"https://avatars2.githubusercontent.com/u/1276480?v=4","gravatar_id":"","url":"https://api.github.com/users/Kinvey","html_url":"https://github.com/Kinvey","followers_url":"https://api.github.com/users/Kinvey/followers","following_url":"https://api.github.com/users/Kinvey/following{/other_user}","gists_url":"https://api.github.com/users/Kinvey/gists{/gist_id}","starred_url":"https://api.github.com/users/Kinvey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kinvey/subscriptions","organizations_url":"https://api.github.com/users/Kinvey/orgs","repos_url":"https://api.github.com/users/Kinvey/repos","events_url":"https://api.github.com/users/Kinvey/events{/privacy}","received_events_url":"https://api.github.com/users/Kinvey/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Kinvey/js-sdk","description":"JavaScript Core SDK - shared code for all Kinvey JS SDKs","fork":false,"url":"https://api.github.com/repos/Kinvey/js-sdk","forks_url":"https://api.github.com/repos/Kinvey/js-sdk/forks","keys_url":"https://api.github.com/repos/Kinvey/js-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Kinvey/js-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Kinvey/js-sdk/teams","hooks_url":"https://api.github.com/repos/Kinvey/js-sdk/hooks","issue_events_url":"https://api.github.com/repos/Kinvey/js-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/Kinvey/js-sdk/events","assignees_url":"https://api.github.com/repos/Kinvey/js-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/Kinvey/js-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/Kinvey/js-sdk/tags","blobs_url":"https://api.github.com/repos/Kinvey/js-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Kinvey/js-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Kinvey/js-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/Kinvey/js-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Kinvey/js-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/Kinvey/js-sdk/languages","stargazers_url":"https://api.github.com/repos/Kinvey/js-sdk/stargazers","contributors_url":"https://api.github.com/repos/Kinvey/js-sdk/contributors","subscribers_url":"https://api.github.com/repos/Kinvey/js-sdk/subscribers","subscription_url":"https://api.github.com/repos/Kinvey/js-sdk/subscription","commits_url":"https://api.github.com/repos/Kinvey/js-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/Kinvey/js-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/Kinvey/js-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/Kinvey/js-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/Kinvey/js-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/Kinvey/js-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Kinvey/js-sdk/merges","archive_url":"https://api.github.com/repos/Kinvey/js-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Kinvey/js-sdk/downloads","issues_url":"https://api.github.com/repos/Kinvey/js-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/Kinvey/js-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/Kinvey/js-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/Kinvey/js-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Kinvey/js-sdk/labels{/name}","releases_url":"https://api.github.com/repos/Kinvey/js-sdk/releases{/id}","deployments_url":"https://api.github.com/repos/Kinvey/js-sdk/deployments","created_at":"2015-02-18T15:20:34Z","updated_at":"2018-03-13T21:36:25Z","pushed_at":"2018-03-15T00:45:25Z","git_url":"git://github.com/Kinvey/js-sdk.git","ssh_url":"git@github.com:Kinvey/js-sdk.git","clone_url":"https://github.com/Kinvey/js-sdk.git","svn_url":"https://github.com/Kinvey/js-sdk","homepage":"http://devcenter.kinvey.com","size":32675,"stargazers_count":10,"watchers_count":10,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":9,"open_issues":6,"watchers":10,"default_branch":"master"}},"base":{"label":"Kinvey:master","ref":"master","sha":"67799f2ab209196cd0d418a47a33793af3d45c18","user":{"login":"Kinvey","id":1276480,"avatar_url":"https://avatars2.githubusercontent.com/u/1276480?v=4","gravatar_id":"","url":"https://api.github.com/users/Kinvey","html_url":"https://github.com/Kinvey","followers_url":"https://api.github.com/users/Kinvey/followers","following_url":"https://api.github.com/users/Kinvey/following{/other_user}","gists_url":"https://api.github.com/users/Kinvey/gists{/gist_id}","starred_url":"https://api.github.com/users/Kinvey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kinvey/subscriptions","organizations_url":"https://api.github.com/users/Kinvey/orgs","repos_url":"https://api.github.com/users/Kinvey/repos","events_url":"https://api.github.com/users/Kinvey/events{/privacy}","received_events_url":"https://api.github.com/users/Kinvey/received_events","type":"Organization","site_admin":false},"repo":{"id":30971013,"name":"js-sdk","full_name":"Kinvey/js-sdk","owner":{"login":"Kinvey","id":1276480,"avatar_url":"https://avatars2.githubusercontent.com/u/1276480?v=4","gravatar_id":"","url":"https://api.github.com/users/Kinvey","html_url":"https://github.com/Kinvey","followers_url":"https://api.github.com/users/Kinvey/followers","following_url":"https://api.github.com/users/Kinvey/following{/other_user}","gists_url":"https://api.github.com/users/Kinvey/gists{/gist_id}","starred_url":"https://api.github.com/users/Kinvey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kinvey/subscriptions","organizations_url":"https://api.github.com/users/Kinvey/orgs","repos_url":"https://api.github.com/users/Kinvey/repos","events_url":"https://api.github.com/users/Kinvey/events{/privacy}","received_events_url":"https://api.github.com/users/Kinvey/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Kinvey/js-sdk","description":"JavaScript Core SDK - shared code for all Kinvey JS SDKs","fork":false,"url":"https://api.github.com/repos/Kinvey/js-sdk","forks_url":"https://api.github.com/repos/Kinvey/js-sdk/forks","keys_url":"https://api.github.com/repos/Kinvey/js-sdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Kinvey/js-sdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Kinvey/js-sdk/teams","hooks_url":"https://api.github.com/repos/Kinvey/js-sdk/hooks","issue_events_url":"https://api.github.com/repos/Kinvey/js-sdk/issues/events{/number}","events_url":"https://api.github.com/repos/Kinvey/js-sdk/events","assignees_url":"https://api.github.com/repos/Kinvey/js-sdk/assignees{/user}","branches_url":"https://api.github.com/repos/Kinvey/js-sdk/branches{/branch}","tags_url":"https://api.github.com/repos/Kinvey/js-sdk/tags","blobs_url":"https://api.github.com/repos/Kinvey/js-sdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Kinvey/js-sdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Kinvey/js-sdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/Kinvey/js-sdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Kinvey/js-sdk/statuses/{sha}","languages_url":"https://api.github.com/repos/Kinvey/js-sdk/languages","stargazers_url":"https://api.github.com/repos/Kinvey/js-sdk/stargazers","contributors_url":"https://api.github.com/repos/Kinvey/js-sdk/contributors","subscribers_url":"https://api.github.com/repos/Kinvey/js-sdk/subscribers","subscription_url":"https://api.github.com/repos/Kinvey/js-sdk/subscription","commits_url":"https://api.github.com/repos/Kinvey/js-sdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/Kinvey/js-sdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/Kinvey/js-sdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/Kinvey/js-sdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/Kinvey/js-sdk/contents/{+path}","compare_url":"https://api.github.com/repos/Kinvey/js-sdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Kinvey/js-sdk/merges","archive_url":"https://api.github.com/repos/Kinvey/js-sdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Kinvey/js-sdk/downloads","issues_url":"https://api.github.com/repos/Kinvey/js-sdk/issues{/number}","pulls_url":"https://api.github.com/repos/Kinvey/js-sdk/pulls{/number}","milestones_url":"https://api.github.com/repos/Kinvey/js-sdk/milestones{/number}","notifications_url":"https://api.github.com/repos/Kinvey/js-sdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Kinvey/js-sdk/labels{/name}","releases_url":"https://api.github.com/repos/Kinvey/js-sdk/releases{/id}","deployments_url":"https://api.github.com/repos/Kinvey/js-sdk/deployments","created_at":"2015-02-18T15:20:34Z","updated_at":"2018-03-13T21:36:25Z","pushed_at":"2018-03-15T00:45:25Z","git_url":"git://github.com/Kinvey/js-sdk.git","ssh_url":"git@github.com:Kinvey/js-sdk.git","clone_url":"https://github.com/Kinvey/js-sdk.git","svn_url":"https://github.com/Kinvey/js-sdk","homepage":"http://devcenter.kinvey.com","size":32675,"stargazers_count":10,"watchers_count":10,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":9,"open_issues":6,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Kinvey/js-sdk/pulls/270"},"html":{"href":"https://github.com/Kinvey/js-sdk/pull/270"},"issue":{"href":"https://api.github.com/repos/Kinvey/js-sdk/issues/270"},"comments":{"href":"https://api.github.com/repos/Kinvey/js-sdk/issues/270/comments"},"review_comments":{"href":"https://api.github.com/repos/Kinvey/js-sdk/pulls/270/comments"},"review_comment":{"href":"https://api.github.com/repos/Kinvey/js-sdk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Kinvey/js-sdk/pulls/270/commits"},"statuses":{"href":"https://api.github.com/repos/Kinvey/js-sdk/statuses/4df7ded2bf973d93bd6b5596b9f86761c9a6c1b4"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"georgiwe"}}