Remove broken references by code

Hi,

Is there a way to automatically remove the broken references in the DBs?

Currently, the only option I found is to do it manually, a red alert message appears in the DB field. But, this is not very helpful, as sometimes the red alert field is not displayed properly inside the field, and hence we are not able to click it to remove it. I get this broken references basically in development, but if by the case they happened further, I want to have a way to automatically handle it.

Thank you.

Best,
Miguel

Miguel, I only have experience with “straight up-and-down” ref fields, so NOT multi-refs. If your question is about the first, then the answer is “yes”: the ref field is just the _id of the row in table referencing it, you can just re-write that _id, no special tricks necessary. But I do not know how you want to establish, in code, that a reference is broken. The only way I see is iterate thru every row, try to “get” the row indicated by the ref-field, and test on an error if you encounter a non-valid ref. Maybe you could also do a query with an .include() and see what happens: if the included array is empty, you might have a clue there, and quicker than “get”-ing in yourself thru code.

Yes, they are mutireference, the window to see the multireferenced fields its not croppped properly, so in order to remove them, I have to play with the width of the field and the scroll page position in the DB-UI, not that helpful. And it will get worst as more reference fields are added. Ill make some tests with ur recommendations and see where it goes. Thanks