I had a collection with an embedMany attribute using strategy=set, so an ArrayCollection was stored. However we deleted some items from the array and now there are some documents with keys not sequential integers.
I need to solve this inconsistence, how can I do that?
You could use $type
operator and query for all documents where your embedManyField
is of type object
. Once you have these documents, apply array_values
to fields where array shall be stored and save them again. Also to avoid such situations in future you should change your collection's strategy to either setArray
or atomicSetArray
.