View Source Sanity.Sync (sanity_sync v0.4.1)
For syncing content from Sanity CMS to Ecto.
suggested-strategy-for-syncing
Suggested strategy for syncing
- Call
sync/2
when a webhook is called to immediately create, update, or delete the document. - Use
sync_all/1
for the inital import of documents and to reconcile created/updates webhooks that were missed. - Use
reconcile_deleted/1
to reconcile any deleted webhooks that were missed.
Link to this section Summary
Functions
Gets a single document. Returns nil
if document does not exist.
Gets a single document. Raises Ecto.NoResultsError
if document does not exist.
Deletes any Sanity.Sync.Doc
records in Ecto that correspond with documents that no longer
exist in Sanity CMS.
Fetches a single document from Sanity. If the document exists then upsert_sanity_doc!/2
will
be called. If the document doesn't exist, then the Sanity.Sync.Doc
for that document will be
deleted.
Fetches all documents from Sanity and calls upsert_sanity_doc!/2
.
Upserts a sanity document.
Link to this section Functions
Gets a single document. Returns nil
if document does not exist.
Gets a single document. Raises Ecto.NoResultsError
if document does not exist.
Deletes any Sanity.Sync.Doc
records in Ecto that correspond with documents that no longer
exist in Sanity CMS.
options
Options
:request_opts
(keyword/0
) - Required. Options to be passed toSanity.request/2
.:batch_size
(pos_integer/0
) - Number of records to fetch per batch. The default value is500
.
Fetches a single document from Sanity. If the document exists then upsert_sanity_doc!/2
will
be called. If the document doesn't exist, then the Sanity.Sync.Doc
for that document will be
deleted.
options
Options
:callback
(function of arity 1) - Callback function that will be called after the document is upserted. It will be passed a map like%{doc: doc, repo: repo}
. This callback is not called when the record is deleted.:request_opts
(keyword/0
) - Required. Options to be passed toSanity.request/2
.
Fetches all documents from Sanity and calls upsert_sanity_doc!/2
.
options
Options
:callback
(function of arity 1) - Callback function that will be called after the document is upserted. It will be passed a map like%{doc: doc, repo: repo}
. This callback is not called when the record is deleted.:request_opts
(keyword/0
) - Required. Options to be passed toSanity.request/2
.:types
(list ofString.t/0
) - Required. List of types to sync.
Upserts a sanity document.
options
Options
:callback
(function of arity 1) - Callback function that will be called after the document is upserted. It will be passed a map like%{doc: doc, repo: repo}
. This callback is not called when the record is deleted.