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
Copy file name to clipboardExpand all lines: guides/release/models/finding-records.md
+22-19Lines changed: 22 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,17 @@ The EmberData store provides an interface for retrieving records of a single typ
2
2
3
3
### Retrieving a Single Record
4
4
5
-
Use [`store.findRecord()`](https://api.emberjs.com/ember-data/release/classes/Store/methods/findRecord?anchor=findRecord) to retrieve a record by its type and ID.
6
-
This will return a promise that fulfills with the requested record:
5
+
Use [`findRecord()`](https://api.emberjs.com/ember-data/5.3/functions/@ember-data%2Fjson-api%2Frequest/findRecord) to retrieve a record by its type and ID.
6
+
This will return a response from the server which has a requested record:
7
7
8
8
```javascript
9
-
// GET /blog-posts/1
10
-
this.store.findRecord('blog-post', 1) // => GET /blog-posts/1
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.
@@ -22,14 +24,14 @@ let blogPost = this.store.peekRecord('blog-post', 1); // => no network request
22
24
23
25
### Retrieving Multiple Records
24
26
25
-
Use [`store.findAll()`](https://api.emberjs.com/ember-data/release/classes/Store/methods/findAll?anchor=findAll) to retrieve all of the records for a given type:
27
+
Use [`query()`](https://api.emberjs.com/ember-data/5.3/functions/@ember-data%2Fjson-api%2Frequest/query) to retrieve all of the records for a given type:
26
28
27
29
```javascript
28
30
// GET /blog-posts
29
-
this.store.findAll('blog-post') // => GET /blog-posts
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:
@@ -38,7 +40,7 @@ Use [`store.peekAll()`](https://api.emberjs.com/ember-data/release/classes/Store
38
40
let blogPosts =this.store.peekAll('blog-post'); // => no network request
39
41
```
40
42
41
-
`store.findAll()` returns a `PromiseArray` that fulfills to a `RecordArray` and `store.peekAll` directly returns a `RecordArray`.
43
+
`findRecord()` returns a `PromiseArray` that fulfills to a `RecordArray` and `store.peekAll` directly returns a `RecordArray`.
42
44
43
45
It's important to note that `RecordArray` is not a JavaScript array, it's an object that implements [`MutableArray`](https://api.emberjs.com/ember/release/classes/MutableArray).
44
46
This is important because, for example, if you want to retrieve records by index,
@@ -47,21 +49,22 @@ the `[]` notation will not work--you'll have to use `objectAt(index)` instead.
47
49
### Querying for Multiple Records
48
50
49
51
EmberData provides the ability to query for records that meet certain criteria.
50
-
Calling [`store.query()`](https://api.emberjs.com/ember-data/release/classes/Store/methods/query?anchor=query) will make a `GET` request with the passed object serialized as query params.
51
-
This method returns a `PromiseArray`in the same way as `findAll`.
52
+
Calling [`query()`](https://api.emberjs.com/ember-data/5.3/functions/@ember-data%2Fjson-api%2Frequest/query) will make a `GET` request with the passed object serialized as query params.
53
+
This method returns a respone from the server in the same way as `findRecord`.
52
54
53
55
For example, we could search for all `person` models who have the name of
0 commit comments