Deleting products with linked documents in Sanity Studio
21 replies
Last updated: May 20, 2022
S
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?
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
K
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
K
This is what the error message is telling you.
May 20, 2022, 6:54 AM
S
It can't be, There is no document with that ref ???
May 20, 2022, 7:04 AM
S
It is not even connected with shopify anymore
May 20, 2022, 7:07 AM
K
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
S
well how do I remove a reference? in my studio it looks like this:
May 20, 2022, 7:15 AM
K
Errr, do you have other document types? Like pages or something maybe? Or do you only have products?
May 20, 2022, 7:17 AM
S
No only products at this point
May 20, 2022, 7:20 AM
S
I found this
May 20, 2022, 7:20 AM
S
is there a media library somewhere I can acces ?
May 20, 2022, 7:20 AM
K
There is a plugin for it yes: https://www.sanity.io/plugins/sanity-plugin-media-library
May 20, 2022, 7:21 AM
S
media library gives me errors
May 20, 2022, 7:49 AM
S
and I still dont know how to fix the ref error
May 20, 2022, 7:50 AM
S
this is what I get when I click on the img Ref
May 20, 2022, 8:00 AM
H
the document with
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?
_id:
e1887e01-fd78-9a12-67fccbc43372needs 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
H
You might not have to delete the document with that
_id, 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
S
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
S
I cant remove the files and it enoys me
May 20, 2022, 8:34 AM
S
This is a real problem if you cant remove it in the studio
May 20, 2022, 8:45 AM
S
the data is still in the back but you just cant reach it
May 20, 2022, 8:45 AM
S
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.