View Source Sanity.Sync (sanity_sync v0.3.0)
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. - TODO
reconcile_deleted
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.
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.
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
- 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
- Required. Options to be passed toSanity.request/2
.
Fetches all documents from Sanity and calls upsert_sanity_doc!/2
.
options
Options
:callback
- 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
- Required. Options to be passed toSanity.request/2
.:types
- Required. List of types to sync.
Upserts a sanity document.
options
Options
:callback
- 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.