You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use [`store.peekRecord()`](https://api.emberjs.com/ember-data/release/classes/Store/methods/peekRecord?anchor=peekRecord) to retrieve a record by its type and ID, without making a network request.
@@ -31,7 +31,7 @@ Use [`query()`](https://api.emberjs.com/ember-data/5.3/functions/@ember-data%2Fj
Use [`store.peekAll()`](https://api.emberjs.com/ember-data/release/classes/Store/methods/peekAll?anchor=peekAll) to retrieve all of the records for a given type that are already loaded into the store, without making a network request:
@@ -69,9 +69,9 @@ const person = result.content.data;
69
69
70
70
### Querying for A Single Record
71
71
72
-
If you are using an adapter that supports server requests capable of returning a single model object,
73
-
EmberData provides a convenience method [`store.queryRecord()`](https://api.emberjs.com/ember-data/release/classes/Store/methods/queryRecord?anchor=queryRecord) that will return a promise that resolves with that single record.
74
-
The request is made via a method `queryRecord()` defined by the adapter.
72
+
If you are using an builder that supports server requests capable of returning a single model object,
73
+
EmberData provides a convenience method [`findRecord()`](https://api.emberjs.com/ember-data/5.3/functions/@ember-data%2Fjson-api%2Frequest/findRecord) that will return a record.
74
+
The request is made via a method `findRecord()` defined by the builders.
75
75
76
76
For example, if your server API provides an endpoint for the currently logged in user:
77
77
@@ -85,43 +85,43 @@ For example, if your server API provides an endpoint for the currently logged in
85
85
}
86
86
```
87
87
88
-
And if the adapter for the `User` model defines a `queryRecord()` method that targets that endpoint:
Then, calling [`store.queryRecord()`](https://api.emberjs.com/ember-data/release/classes/Store/methods/queryRecord?anchor=queryRecord) will retrieve that object from the server:
102
+
Then, calling `queryData()` will retrieve that object from the server:
console.log(`Currently logged in as ${username}`);
108
110
```
109
111
110
-
As in the case of `store.query()`, a query object can also be passed to `store.queryRecord()` and is available for the adapter's `queryRecord()` to use to qualify the request.
111
-
However the adapter must return a single model object, not an array containing one element,
112
+
As in the case of `query()`, a query object can also be passed to `query()` and is available for the builder's `query()` to use to qualify the request.
113
+
However the builder must return a single model object, not an array containing one element,
112
114
otherwise EmberData will throw an exception.
113
115
114
-
Note that Ember's default [JSON:API adapter](https://api.emberjs.com/ember-data/release/classes/JSONAPIAdapter) does not provide the functionality needed to support `queryRecord()` directly as it relies on REST request definitions that return result data in the form of an array.
115
-
116
-
If your server API or your adapter only provides array responses but you wish to retrieve just a single record, you can alternatively use the `query()` method as follows:
116
+
If your server API or your builder only provides array responses but you wish to retrieve just a single record, you can alternatively use the `query()` method as follows:
0 commit comments