Skip to content

Commit b5dadbd

Browse files
committed
Convert this.store to just store in the code examples
1 parent 215ca9e commit b5dadbd

File tree

12 files changed

+28
-26
lines changed

12 files changed

+28
-26
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
const user = this.store.peekRecord('user', '1');
1+
const user = store.peekRecord('user', '1');
22
await user.destroyRecord();
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { deleteRecord } from '@ember-data/json-api/request';
22

3-
const user = this.store.peekRecord('user', '1');
4-
this.store.deleteRecord(user);
5-
await this.store.request(deleteRecord(user));
6-
this.store.unloadRecord(user);
3+
const user = store.peekRecord('user', '1');
4+
store.deleteRecord(user);
5+
await store.request(deleteRecord(user));
6+
store.unloadRecord(user);
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { query } from '@ember-data/json-api/request';
22

3-
await this.store.request(query('user'));
4-
const users = this.store.peekAll('user')
3+
const result = await store.request(query('user'));
4+
const users = result.content.data;
5+
// or
6+
const users = store.peekAll('user')
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { findRecord } from '@ember-data/json-api/request';
22

3-
const result = await this.store.request(findRecord('user', '1'));
3+
const result = await store.request(findRecord('user', '1'));
44
const user = result.content.data

snippets/fetching-data/find-record/own-builder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ export default {
3535

3636
// Somewhere in app
3737
const fetchOptions = findRecord('user', '1', { include: 'friends' });
38-
const result = await this.store.request(fetchOptions)
38+
const result = await store.request(fetchOptions)
3939
const user = result.content.data
4040
// or using identifier for findRecord builder
4141
const fetchOptions = findRecord({ type: 'user', id: '1' }, { include: 'friends' });
42-
const result = await this.store.request(fetchOptions)
42+
const result = await store.request(fetchOptions)
4343
const user = result.content.data
4444

4545

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { query } from '@ember-data/json-api/request';
22

3-
const result = await this.store.request(query('user', { ...params, limit: 1 }));
3+
const result = await store.request(query('user', { ...params, limit: 1 }));
44
const user = result.content.data[0] ?? null;

snippets/fetching-data/query/new.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { query } from '@ember-data/json-api/request';
22

3-
const result = await this.store.request(query('user', { filter: { name: 'John' } }));
3+
const result = await store.request(query('user', { filter: { name: 'John' } }));
44
const users = result.content.data;

snippets/updating-data/create-record/handler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ export default class extends RequestManager {
3939
// then in your app just use createRecord builder and let handler care about serialization
4040
import { createRecord } from '@ember-data/json-api/request';
4141

42-
const request = createRecord(record);
43-
await this.store.request(request);
42+
const requestObj = createRecord(record);
43+
await store.request(requestObj);
4444

4545
// or overwrite body if you need to, handler will not touch it
4646
import { createRecord } from '@ember-data/json-api/request';
4747

48-
const record = this.store.createRecord('feature', { name: "rest-enabled" });
48+
const record = store.createRecord('feature', { name: "rest-enabled" });
4949
const request = createRecord(record);
5050
// For some reason your endpoint for 'features' is not JSON:API compliant
5151
request.body = JSON.stringify({ name: 'rest-enabled' })
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { recordIdentifierFor } from '@ember-data/store';
22
import { createRecord, serializeResources } from '@ember-data/json-api/request';
33

4-
const record = this.store.createRecord('user', {});
4+
const record = store.createRecord('user', {});
55
const request = createRecord(record);
66
// You can in place add body to request options
77
request.body = JSON.stringify(
88
serializeResources(
9-
this.store.cache,
9+
store.cache,
1010
recordIdentifierFor(record)
1111
)
1212
);
1313

14-
await this.store.request(request);
14+
await store.request(request);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { recordIdentifierFor } from '@ember-data/store';
22
import { createRecord, serializeResources } from '@ember-data/json-api/request';
33

4-
const record = this.store.createRecord('user', {});
4+
const record = store.createRecord('user', {});
55
const request = createRecord(record);
66
request.body = JSON.stringify(
77
serializeResources(
8-
this.store.cache,
8+
store.cache,
99
recordIdentifierFor(record)
1010
)
1111
);
1212

13-
await this.store.request(request);
13+
await store.request(request);

0 commit comments

Comments
 (0)