Created
March 20, 2019 08:16
-
-
Save kmelve/8686114b25e84530d265064cd3b2f13d to your computer and use it in GitHub Desktop.
Bulk deletion in Sanity.io with webtask.io/make
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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