I have created a Sanity.io CMS, I have made some alterations to the schema after content had already been entered. The problem now is that the content is still saved somewhere inside the cms and I have no way to remove it.
Asked
Active
Viewed 2,874 times
2 Answers
16
There are several ways of deleting documents which are no longer visible in the Studio:
- Make the Studio render the old documents, either by temporarily putting back the original schema, or defining a list using Structure Builder which will render the old docs
- Write a script which queries for all documents by that type, and have the script delete them
- Use the Sanity CLI to query for and later delete the documents, e.g.
sanity documents query '*[_type == "unwantedType"]._id'
and thensanity documents delete [list-of-unwanted-doc-ids]

thomax
- 9,213
- 3
- 49
- 68
-
1`sanity documents fetch` wasn't working for me; it looks like it has been renamed to `sanity documents query`. – coreyward Dec 14 '19 at 00:43
0
I re-imported the documents that I had changed/ removed back into the schema.js file and removed them via the studio. The other alternative, for now, is to use the API to delete the records.

Aiden Barrett
- 329
- 1
- 4
- 11