View Source Sanity.Sync (sanity_sync v0.2.0)
For syncing content from Sanity CMS to Ecto.
Link to this section Summary
Functions
Gets a single document. Raises Ecto.NoResultsError if document does not exist.
Gets a single document. Returns nil 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. Raises Ecto.NoResultsError if document does not exist.
Gets a single document. Returns nil 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.
This function can be called when a webhook is received to sync a 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.sanity_config- Sanity configuration. SeeSanity.request/2.
Fetches all documents from Sanity and calls upsert_sanity_doc!/2.
options
Options
callback- Callback function that will be called after each document is upserted. It will be passed a map like%{doc: doc, repo: repo}.sanity_config- Sanity configuration. SeeSanity.request/2.types- List of types to sync. If omitted, all types will be synced.
Upserts a sanity document.