Skip to content

Instantly share code, notes, and snippets.

@kmelve
Created March 20, 2019 08:16
Show Gist options
  • Select an option

  • Save kmelve/8686114b25e84530d265064cd3b2f13d to your computer and use it in GitHub Desktop.

Select an option

Save kmelve/8686114b25e84530d265064cd3b2f13d to your computer and use it in GitHub Desktop.
Bulk deletion in Sanity.io with webtask.io/make
// Remember to add npm dependencies (click the 🔧)
const SanityClient = require('@sanity/client');
const client = token => SanityClient({
projectId: '<YourProjectID>',
dataset: 'production',
useCdn: false,
token
});
module.exports = async function(context, cb) {
// Remember to add the token to secrets (click the 🔧)
const { SANITY_TOKEN } = context.secrets;
const res = await client(SANITY_TOKEN).delete({query: "*[delete]"});
await cb(null, {deleted: res});
};
/*
Given the field:
{
name: 'delete',
type: 'boolean',
title: 'Mark for deletion',
description: 'This marks this document for scheduled deletion'
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment