Prevent a Mongo error when tag_ids are set to nil

At present, when the tag ids for a type of tag are set to nil (eg. `organisation_ids = nil`), the operation will raise an error as the MongoDB query is expecting an array.

This changes the writer method to make sure we only request tag IDs as an array when we fetch tags from the database.