Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,19 @@ class ContentfulCache {
/**
* Helper function to run a full sync against Contentful. All content will be
* pulled down with paginated API requests and cached.
* @param {Object} config - Optional flags.
* @param {Boolean} config.purge - Whether the database should be flushed
* before a re-sync. Useful if the cache has become corrupted. Use with care
* since the purge will happen whether or not the Contentful API is reachable.
* @return {Promise} - Fulfilled when the sync has finished.
*/
async sync() {
async sync(config = {}) {
if (config.purge) {
return this.cache.client.flushdb((err) => {
if (err) console.error(err);
this.syncPaged();
});
}
return this.syncPaged();
}

Expand Down