Go Behind the Experience to see how Tecovas brings the West to life with Sanity ๐Ÿค  July 18th

Deleting products with linked documents in Sanity Studio

21 replies
Last updated: May 20, 2022
Hi guys,
Yesterday I tryed shopify connect with sanity, and I removed the store and token but now I get this when I try to delete some of the products. How can resolve this?
May 20, 2022, 6:50 AM
You are trying to delete a document which is referenced by 2 other documents, which is not possible for security reasons. Open these documents in the studio, and remove the reference to the document you are trying to delete.
May 20, 2022, 6:54 AM
This is what the error message is telling you.
May 20, 2022, 6:54 AM
It can't be, There is no document with that ref ???
May 20, 2022, 7:04 AM
It is not even connected with shopify anymore
May 20, 2022, 7:07 AM
This has nothing to do with Shopify I'm afraid. It's about linked documents in your studio, as the dialog and the error indicate.
May 20, 2022, 7:10 AM
well how do I remove a reference? in my studio it looks like this:
May 20, 2022, 7:15 AM
Errr, do you have other document types? Like pages or something maybe? Or do you only have products?
May 20, 2022, 7:17 AM
No only products at this point
May 20, 2022, 7:20 AM
I found this
May 20, 2022, 7:20 AM
is there a media library somewhere I can acces ?
May 20, 2022, 7:20 AM
May 20, 2022, 7:21 AM
media library gives me errors
May 20, 2022, 7:49 AM
and I still dont know how to fix the ref error
May 20, 2022, 7:50 AM
this is what I get when I click on the img Ref
May 20, 2022, 8:00 AM
the document with
needs to be deleted in order to delete the product you are trying to delete. ๐Ÿ™‚ In order to get all documents that have references you can put the following query into vision:
*[]{_id, title , "references":*[ references(^._id)]}[length(references)>0]

If the studio crashes when you attempt to access them with the GUI, you might have to delete them with a script instead. Is there any particular reason you want to delete these products or are you simply attempting to learn more about Sanity?
May 20, 2022, 8:02 AM
You might not have to delete the document with that
, but you would need to unset the reference. In practical terms this means finding the links to other documents and deleting the links in the studio.
May 20, 2022, 8:04 AM
I hooked Shopify to it and it added some products to my studio that didnt go as planned and so I disconnected it but the ref is still there for some reason. I just put that query you gave me in vision and its not crashing. but I need to clean it up so I can add my own files.
May 20, 2022, 8:12 AM
I cant remove the files and it enoys me
May 20, 2022, 8:34 AM
This is a real problem if you cant remove it in the studio
May 20, 2022, 8:45 AM
the data is still in the back but you just cant reach it
May 20, 2022, 8:45 AM
nvm I deleted the whole dataset
May 20, 2022, 9:15 AM

Sanityโ€“ build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?