How to add the tag without duplication?

You can first do a query for the uid and then do the mutation only if tags are absent. You can take a look at conditional upserts for example.