Find a Object in Doc and replace with Empty Array

I am wondering if there is a way in N1QL to search for an empty object called emails and delete it and replace it with an empty array called emails. Some of my docs have already a array called emails which either has objects in them or are empty, those i dont want to delete and replace.

UPDATE default AS d
SET  v.emails = [] FOR v WITHIN d WHEN OBJECT_LENGTH(v.emails) == 0 END,
           d.emails = CASE WHEN OBJECT_LENGTH(v.emails)  = 0 THEN [] ELSE d.emails  END
WHERE ANY v WITHIN {d} SATISFIES OBJECT_LENGTH(v.emails) == 0 END

Required primary index. If you know path of the emails it makes easier.