Build an expression that can be used to filter which items of a given Model are synchronized down from the GraphQL service. E.g.,
import { DataStore, syncExpression } from 'aws-amplify/datastore';import { Post, Comment } from './models';DataStore.configure({ syncExpressions: [ syncExpression(Post, () => { return (post) => post.rating.gt(5); }), syncExpression(Comment, () => { return (comment) => comment.status.eq('active'); }) ]}); Copy
import { DataStore, syncExpression } from 'aws-amplify/datastore';import { Post, Comment } from './models';DataStore.configure({ syncExpressions: [ syncExpression(Post, () => { return (post) => post.rating.gt(5); }), syncExpression(Comment, () => { return (comment) => comment.status.eq('active'); }) ]});
When DataStore starts syncing, only Posts with rating > 5 and Comments with status === 'active' will be synced down to the user's local store.
rating > 5
status === 'active'
The Model from the schema.
A function that builds a condition object that can describe how to filter the model.
An sync expression object that can be attached to the DataStore syncExpressions configuration property.
syncExpressions
Build an expression that can be used to filter which items of a given Model are synchronized down from the GraphQL service. E.g.,
When DataStore starts syncing, only Posts with
rating > 5
and Comments withstatus === 'active'
will be synced down to the user's local store.