Skip to content

Commit ad7bc17

Browse files
authored
fix(data): fix broken DataStore code snippet; fix spelling and grammatical errors (#5140)
1 parent c15a76e commit ad7bc17

File tree

12 files changed

+35
-34
lines changed

12 files changed

+35
-34
lines changed

src/fragments/lib-v1/datastore/ios/sync/50-selectiveSync.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ Developers should only specify a single `syncExpression` per model. Any subseque
2727

2828
</Callout>
2929

30-
### Reevaluate expressions at runtime
30+
### Re-evaluate expressions at runtime
3131
Sync expressions get evaluated whenever DataStore starts.
32-
In order to have your expressions reevaluated, you can execute `Amplify.DataStore.clear()` or `Amplify.DataStore.stop()` followed by `Amplify.DataStore.start()`.
32+
In order to have your expressions re-evaluated, you can execute `Amplify.DataStore.clear()` or `Amplify.DataStore.stop()` followed by `Amplify.DataStore.start()`.
3333

3434
If you have the following expression and you want to change the filter that gets applied at runtime, you can do the following:
3535

@@ -64,7 +64,7 @@ func changeSync() {
6464
}
6565
}
6666
```
67-
Each time DataStore starts (via `start` or any other operation: `query`, `save`, `delete`, or `observe`), DataStore will reevaluate the `syncExpressions`.
67+
Each time DataStore starts (via `start` or any other operation: `query`, `save`, `delete`, or `observe`), DataStore will re-evaluate the `syncExpressions`.
6868

6969
In the above case, the predicate will contain the value `1`, so all Posts with `rating > 1` will get synced down.
7070

@@ -96,7 +96,7 @@ func changeSync() {
9696
}
9797
```
9898

99-
This will clear the contents of your local store, reevaluate your sync expressions and re-sync the data from the cloud, applying all of the specified predicates to the sync queries.
99+
This will clear the contents of your local store, re-evaluate your sync expressions and re-sync the data from the cloud, applying all of the specified predicates to the sync queries.
100100

101101
You can also have your sync expression return `QueryPredicateConstant.all` in order to remove any filtering for that model. This will have the same effect as the default sync behavior.
102102

src/fragments/lib-v1/datastore/native_common/setup-env-cli.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ amplify add api
1313
amplify update api
1414
```
1515

16-
The CLI will prompt you to configure your API. Select **GraphQL** as the API type and reply to the questions as shown below. Conflict detection is **required** when using the DataStore to sync data with the cloud.
16+
The CLI will prompt you to configure your API. Select **GraphQL** as the API type and reply to the questions as shown below. Conflict detection is **required** when using DataStore to sync data with the cloud.
1717

1818
```console
1919
? Please select from one of the below mentioned services:

src/fragments/lib-v1/datastore/native_common/sync.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ Once you're happy with your application, you can start syncing with the cloud by
99

1010
## Setup cloud sync
1111

12-
Synchronization between offline and online data can be tricky. DataStore goal is to remove that burden from the application code and handle all data consistency and reconciliation between local and remote behind the scenes, while developers focus on their application logic. Up to this point the focus was to setup a local datastore that works offline and has all the capabilities you would expect from a data persistence framework.
12+
Synchronization between offline and online data can be tricky. DataStore's goal is to remove that burden from the application code and handle all data consistency and reconciliation between local and remote behind the scenes, while developers focus on their application logic. Up to this point the focus was to setup a local data store that works offline and has all the capabilities you would expect from a data persistence framework.
1313

14-
The next step is to make sure the local saved data is synchronized with a cloud backend powered by [AWS AppSync](https://aws.amazon.com/appsync/).
14+
The next step is to make sure the locally saved data is synchronized with a cloud backend powered by [AWS AppSync](https://aws.amazon.com/appsync/).
1515

1616
<Callout>
1717

18-
**Note:** Syncing data between the cloud and the local device starts automatically whenever you run any DataStore operation after your app is setup.
18+
**Note:** Syncing data between the cloud and the local device starts automatically whenever you run any DataStore operation after your app is set up.
1919

2020
</Callout>
2121

src/fragments/lib/datastore/flutter/relational/save-many-snippet.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Future<void> savePostAndEditor() async {
1818
// secondly, you save the editor/user
1919
await Amplify.DataStore.save(editor);
2020
21-
// then you save the mode that links a post with an editor
21+
// then you save the model that links a post with an editor
2222
await Amplify.DataStore.save(postEditor);
2323
print('Saved user, post and postEditor!');
2424
}

src/fragments/lib/datastore/js/data-access/observe-update-snippet.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function App() {
3030
value={post?.title ?? ""}
3131
onChange={({ target: { value } }) => {
3232
/**
33-
* Each keypress updates the post in local react state.
33+
* Each keypress updates the post in local React state.
3434
*/
3535
setPost(
3636
Post.copyOf(post!, (draft) => {
@@ -44,12 +44,13 @@ function App() {
4444
value="Save"
4545
onClick={async () => {
4646
/**
47-
* This post is already up to date because observeQuery updated it.
47+
* This post is already up-to-date because `observeQuery` updated it.
4848
*/
4949
await DataStore.save(post!);
5050
console.log("Post saved");
5151
}}
5252
/>
5353
</>
5454
);
55+
}
5556
```

src/fragments/lib/datastore/js/examples.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import "./App.css";
1111
import { Amplify, DataStore, Predicates } from "aws-amplify";
1212
import { Post, PostStatus } from "./models";
1313

14-
//Use next two lines only if syncing with the cloud
14+
// Use next two lines only if syncing with the cloud
1515
import awsconfig from "./aws-exports";
1616
Amplify.configure(awsconfig);
1717

src/fragments/lib/datastore/js/real-time/observe-snippet.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const subscription = DataStore.observe(Post, id).subscribe(msg => {
1414
});
1515
```
1616

17-
Closing a subscription
17+
Closing a subscription:
1818

1919
```js
2020
const subscription = DataStore.observe(Post, id).subscribe(msg => {

src/fragments/lib/datastore/js/relational/query-many-snippet.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ const post = await DataStore.save(new Post({
77
title: 'Amplify Weekly'
88
rating: 10,
99
status: PostStatus.ACTIVE,
10-
}))
10+
}));
1111

1212
const user = await DataStore.save(new User({
1313
username: 'rene'
14-
}))
14+
}));
1515

1616
const postEditor = await DataStore.save(new PostEditor({
1717
post: post,
1818
user: user
19-
}))
19+
}));
2020
```
2121

2222
Here we've first created a new `Post` instance and a new `User` instance. Then, saved those instances to a new instance of our join model `PostEditor`.
@@ -26,23 +26,23 @@ Here we've first created a new `Post` instance and a new `User` instance. Then,
2626
To query many-to-many relationships, use a nested predicate to filter the target model by the source model's id:
2727

2828
```js
29-
const editors = await DataStore.query(User, u => u.posts.post.id.eq(post.id))
29+
const editors = await DataStore.query(User, u => u.posts.post.id.eq(post.id));
3030
```
3131

3232
### Delete
3333

3434
Deleting the join model instance will not delete any source model instances.
3535

3636
```js
37-
await DataStore.delete(toBeDeletedPostEditor)
37+
await DataStore.delete(toBeDeletedPostEditor);
3838
```
3939

4040
Both the `Post` and the `User` instances will not be deleted. Only the join model instances containing the link between a `Post` and a `User`.
4141

4242
Deleting a source model instance will also delete the join model instances containing the source model instance.
4343

4444
```js
45-
await DataStore.delete(toBeDeletedUser)
45+
await DataStore.delete(toBeDeletedUser);
4646
```
47-
The `toBeDeletedUser` User instance and all `PostEditor` instances where `user` is linked to `toBeDeletedUser` will be deleted.
4847

48+
The `toBeDeletedUser` User instance and all `PostEditor` instances where `user` is linked to `toBeDeletedUser` will be deleted.

src/fragments/lib/datastore/js/sync/50-selectiveSync.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async function changeSync() {
5151
rating = 1;
5252
await DataStore.stop();
5353
await DataStore.start();
54-
}
54+
};
5555
```
5656

5757
Upon calling `DataStore.start()` (or executing a DataStore operation, e.g., `query`, `save`, `delete`, or `observe`), DataStore will reevaluate the `syncExpressions`.
@@ -71,7 +71,7 @@ async function changeSync() {
7171
rating = 8;
7272
await DataStore.clear();
7373
await DataStore.start();
74-
}
74+
};
7575
```
7676
This will clear the contents of your local store, reevaluate your sync expressions and re-sync the data from the cloud, applying all of the specified predicates to the sync queries.
7777

src/fragments/lib/datastore/native_common/setup-auth-rules.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import datastoreClearCallout from '/src/fragments/lib/datastore/native_common/ca
1818

1919
### Per User / Owner Based Data Access
2020

21-
The following are commonly used patterns for owner based authorization. For more information on how to tune these examples, please see the [CLI documentation on owner based authorization](/cli/graphql/authorization-rules/#per-user--owner-based-data-access).
21+
The following are commonly used patterns for owner based authorization. For more information on how to fine tune these examples, please see the [CLI documentation on owner based authorization](/cli/graphql/authorization-rules/#per-user--owner-based-data-access).
2222

2323
- Create/Read/Update/Delete mutations are private to the owner.
2424

@@ -45,13 +45,13 @@ type YourModel
4545

4646
### Static Group Authorization
4747

48-
The following are commonly used patterns for static group authorization. For more information on how to tune these examples, please see the [CLI documentation on static group authorization](/cli/graphql/authorization-rules/#user-group-based-data-access).
48+
The following are commonly used patterns for static group authorization. For more information on how to fine tune these examples, please see the [CLI documentation on static group authorization](/cli/graphql/authorization-rules/#user-group-based-data-access).
4949

5050
- Users belonging to the "Admin" group can CRUD (create, read, update, and delete), others cannot access anything.
5151

5252
```graphql
5353
type YourModel @model @auth(rules: [{ allow: groups,
54-
groups: ["Admin"] }]) {
54+
groups: ["Admin"] }]) {
5555
...
5656
}
5757
```
@@ -73,7 +73,7 @@ type YourModel
7373

7474
### Owner and Static Group Combined
7575

76-
The following are commonly used patterns for combining owner and static group authorization. For more information on how to tune these examples, please see the [CLI documentation on static group authorization](/cli/graphql/authorization-rules#static-group-authorization).
76+
The following are commonly used patterns for combining owner and static group authorization. For more information on how to fine tune these examples, please see the [CLI documentation on static group authorization](/cli/graphql/authorization-rules#static-group-authorization).
7777

7878
- Users have their own data, but users who belong to the `Admin` group have access to their data and anyone else in that group. Users in the `Admin` group have the ability to make mutation on behalf of users not in the `Admin` group
7979

@@ -87,7 +87,7 @@ type YourModel
8787

8888
### Public Data Access
8989

90-
The following are commonly used patterns to grant everyone access. For more information on how to tune these examples, please see the [CLI documentation on public data access](/cli/graphql/authorization-rules/#public-data-access).
90+
The following are commonly used patterns to grant everyone access. For more information on how to fine tune these examples, please see the [CLI documentation on public data access](/cli/graphql/authorization-rules/#public-data-access).
9191

9292
- Auth provider is API Key
9393

@@ -107,7 +107,7 @@ type YourModel @model @auth(rules: [{ allow: public, provider: iam }]) {
107107

108108
### Signed-in User Data Access
109109

110-
The following are commonly used patterns for private authorization. For more information on how to tune these examples, please see the [CLI documentation on signed-in user data access](https://docs.amplify.aws/cli/graphql/authorization-rules/#signed-in-user-data-access).
110+
The following are commonly used patterns for private authorization. For more information on how to fine tune these examples, please see the [CLI documentation on signed-in user data access](https://docs.amplify.aws/cli/graphql/authorization-rules/#signed-in-user-data-access).
111111

112112
- Cognito user pool authenticated users can CRUD all posts, regardless of who created it. Guest users do not have access.
113113

@@ -127,7 +127,7 @@ type YourModel @model @auth(rules: [{ allow: private, provider: iam }]) {
127127

128128
### Owner based Authorization with OIDC provider
129129

130-
The following are commonly used patterns for owner based authorization using a 3rd party OIDC provider (e.g. Facebook, Google, etc...). For more information on how to tune these examples, please see the [CLI documentation on using an oidc authorization provider](/cli/graphql/authorization-rules/#using-oidc-authorization-provider).
130+
The following are commonly used patterns for owner based authorization using a 3rd party OIDC provider (e.g. Facebook, Google, etc...). For more information on how to fine tune these examples, please see the [CLI documentation on using an oidc authorization provider](/cli/graphql/authorization-rules/#using-oidc-authorization-provider).
131131

132132
- Using a 3rd party OIDC provider to achieve owner based authorization.
133133

@@ -153,7 +153,7 @@ import flutterOidc from '/src/fragments/lib/datastore/flutter/setup-auth-rules/o
153153

154154
### Static Group Authorization with OIDC provider
155155

156-
The following are commonly used patterns for using `groupClaims` to achieve group based authorization using a 3rd party OIDC provider. For more information on how to tune these examples, please see the [CLI documentation on static group authorization](/cli/graphql/authorization-rules#custom-claims).
156+
The following are commonly used patterns for using `groupClaims` to achieve group based authorization using a 3rd party OIDC provider. For more information on how to fine tune these examples, please see the [CLI documentation on static group authorization](/cli/graphql/authorization-rules#custom-claims).
157157

158158
- Using a custom value for `groupClaim` to achieve static group authorization with a 3rd party OIDC provider.
159159

0 commit comments

Comments
 (0)