Structured Content 2022: Join our conference to explore fresh perspectives on content and digital experiences →

Deleting content after accidentally deleting the schema first

5 replies
Last updated: Feb 9, 2021

Hi guys! So, I created a Schema, added content to it, and published. Then I deleted the schema in my code without deleting the content first. How can I delete this data now? I am still getting the data when fetching it

Feb 9, 2021, 2:39 PM

If you know the document ID(s), you could run

sanity documents delete <id>
. If there's a bunch of docs, you could consider putting back a schema with the same name to see things in the studio again, or use a script instead: https://github.com/sanity-io/sanity-recipes/blob/master/snippets/deleteDocsByFilter.js

Feb 9, 2021, 2:50 PM

If you know the document ID(s), you could run

sanity documents delete <id>
. If there's a bunch of docs, you could consider putting back a schema with the same name to see things in the studio again, or use a script instead: https://github.com/sanity-io/sanity-recipes/blob/master/snippets/deleteDocsByFilter.js

Feb 9, 2021, 2:50 PM

awesome! just found these here

Feb 9, 2021, 2:52 PM

tks

Feb 9, 2021, 2:52 PM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.