Skip to content

Commit

Permalink
Merge pull request #4592 from pangratz/doc-refresh-query
Browse files Browse the repository at this point in the history
[DOC] Add documentation for query#update() to refresh query
  • Loading branch information
wecc authored Oct 20, 2016
2 parents bdc1d66 + 851a7c1 commit 70ea8c0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@ const { get } = Ember;
may trigger a search on the server, whose results would be loaded
into an instance of the `AdapterPopulatedRecordArray`.
---
If you want to update the array and get the latest records from the
adapter, you can invoke [`update()`](#method_update):
Example
```javascript
// GET /users?isAdmin=true
var admins = store.query('user', { isAdmin: true });
admins.then(function() {
console.log(admins.get("length")); // 42
});
// somewhere later in the app code, when new admins have been created
// in the meantime
//
// GET /users?isAdmin=true
admins.update().then(function() {
admins.get('isUpdating'); // false
console.log(admins.get("length")); // 123
});
admins.get('isUpdating'); // true
```
@class AdapterPopulatedRecordArray
@namespace DS
@extends DS.RecordArray
Expand Down
3 changes: 2 additions & 1 deletion addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,8 @@ Store = Service.extend({
Parameters: { "ids" => ["1", "2", "3"] }
```
This method returns a promise, which is resolved with a `RecordArray`
This method returns a promise, which is resolved with an
[`AdapterPopulatedRecordArray`](http://emberjs.com/api/data/classes/DS.AdapterPopulatedRecordArray.html)
once the server returns.
@since 1.13.0
Expand Down

0 comments on commit 70ea8c0

Please sign in to comment.