Repository: parse-community/Parse-SDK-JS
Pull request #1002 (2019-11-20 18:18:15)

Support query.fromNetwork()
Taken from Android API [fromNetwork()](http://parseplatform.org/Parse-SDK-Android/api/com/parse/ParseQuery.html#fromNetwork--)

Can be used to switch from localDatastore back to the server.

codecov[bot]: # [Codecov](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/1002?src=pr&el=h1) Report
> Merging [#1002](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/1002?src=pr&el=desc) into [master](https://codecov.io/gh/parse-community/Parse-SDK-JS/commit/a9c3000feb43d01e6735ab79214dbdd529ec7bf1?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/1002/graphs/tree.svg?width=650&token=8nCENM0QHj&height=150&src=pr)](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/1002?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #1002      +/-   ##
==========================================
+ Coverage   91.91%   91.91%   +<.01%     
==========================================
  Files          53       53              
  Lines        5094     5098       +4     
  Branches     1145     1145              
==========================================
+ Hits         4682     4686       +4     
  Misses        412      412
```


| [Impacted Files](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/1002?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/ParseQuery.js](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/1002/diff?src=pr&el=tree#diff-c3JjL1BhcnNlUXVlcnkuanM=) | `96.03% <100%> (+0.02%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/1002?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/1002?src=pr&el=footer). Last update [a9c3000...5654508](https://codecov.io/gh/parse-community/Parse-SDK-JS/pull/1002?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/src/ParseQuery.js b/src/ParseQuery.js
index 9cd6a0c..0391b2a 100644
--- a/src/ParseQuery.js
+++ b/src/ParseQuery.js
@@ -1774,6 +1774,17 @@ class ParseQuery {
     return query;
   }
 
+  /**
+   * Change the source of this query to the server.
+   *
+   * @return {Parse.Query} Returns the query, so you can chain this call.
+   */
+  fromNetwork(): ParseQuery {
+    this._queriesLocalDatastore = false;
+    this._localDatastorePinName = null;
+    return this;
+  }
+
   /**
    * Changes the source of this query to all pinned objects.
    *


Test patch:
diff --git a/src/__tests__/ParseQuery-test.js b/src/__tests__/ParseQuery-test.js
index 2275089..5038ce3 100644
--- a/src/__tests__/ParseQuery-test.js
+++ b/src/__tests__/ParseQuery-test.js
@@ -2346,6 +2346,10 @@ describe('ParseQuery LocalDatastore', () => {
     q.fromPin();
     expect(q._queriesLocalDatastore).toBe(true);
     expect(q._localDatastorePinName).toBe(DEFAULT_PIN);
+    const query = q.fromNetwork();
+    expect(q._queriesLocalDatastore).toBe(false);
+    expect(q._localDatastorePinName).toBe(null);
+    expect(query).toEqual(q);
   });
 
   it('can query from pin with name', () => {