From 851a7c13c38d1d3e0b745992cab9b3f62e0ad157 Mon Sep 17 00:00:00 2001 From: pangratz Date: Wed, 19 Oct 2016 15:32:25 +0300 Subject: [PATCH] [DOC] Add documentation for query#update() to refresh query --- .../adapter-populated-record-array.js | 27 +++++++++++++++++++ addon/-private/system/store.js | 3 ++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/addon/-private/system/record-arrays/adapter-populated-record-array.js b/addon/-private/system/record-arrays/adapter-populated-record-array.js index 7727e85bf72..8448b7470b0 100644 --- a/addon/-private/system/record-arrays/adapter-populated-record-array.js +++ b/addon/-private/system/record-arrays/adapter-populated-record-array.js @@ -14,6 +14,33 @@ var get = Ember.get; 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 diff --git a/addon/-private/system/store.js b/addon/-private/system/store.js index 8953f59f7dc..e86825de649 100644 --- a/addon/-private/system/store.js +++ b/addon/-private/system/store.js @@ -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