```java
// Tests only against the local state
if (post.getTitle().startsWith("[Amplify]")) {
Amplify.DataStore.save(post,
update -> { /* handle result */ },
failure -> { /* handle failure */}
);
}
// Only applies the update if the data in the remote backend satisfies the criteria
Amplify.DataStore.save(post, Post.TITLE.beginsWith("[Amplify]"),
update -> { /* handle result */ },
failure -> { /* handle failure */ }
);
```
```kotlin
// Tests only against the local state
if (post.title.startsWith("[Amplify]")) {
Amplify.DataStore.save(post,
{ /* handle result */ },
{ /* handle failure */}
)
}
// Only applies the update if the data in the remote backend satisfies the criteria
Amplify.DataStore.save(post, Post.TITLE.beginsWith("[Amplify]"),
{ /* handle result */ },
{ /* handle failure */ }
)
```
```kotlin
// Tests only against the local state
if (post.title.starts("[Amplify]")) {
try {
Amplify.DataStore.save(post)
} catch (error: DataStoreException) {
// handle error
}
}
// Only applies the update if the data in the remote backend satisfies the criteria
Amplify.DataStore.save(post, Post.TITLE.beginsWith("[Amplify]"),
{ /* handle result */ },
{ /* handle failure */ }
)
```
```java
// Tests only against the local state
if (post.getTitle().startsWith("[Amplify]")) {
RxAmplify.DataStore.save(post)
.subscribe(
update -> { /* handle result */ },
failure -> { /* handle failure */}
);
}
// Only applies the update if the data in the remote backend satisfies the criteria
RxAmplify.DataStore.save(post, Post.TITLE.beginsWith("[Amplify]"))
.subscribe(
update -> { /* handle result */ },
failure -> { /* handle failure */ }
);
```