I have a case where our server code is on spring boot use mongodb as database. The apis were previously only supported for android and my task was to integrate changes for webapp as well.
The mongodb has int
field androidId
being stored in devices collection. I need to support web devices as well. So my solution was to change int androidId
to string platfromId
and add a new string
field platform
to the collection.
But I was told that I should add a new field webId
instead because we might use greater than
and less than
operators later for android. Currently we only use equals
operator which is indexed. Concern of having to index platfromId
and platfrom
was also raised (but if thats the case, androidId
, webId
etc will also be indexed with the other approach).
So, my question is what is the pros and cons of both approach? Have multiple fields depending upon the platfrom such as androidId
, webId
, iosId
etc vs having more generic fields like platfromId
and platfrom
?
I think it'll add a lot of boilerplate to the code and make in unmaintainable later on and should use generic fields.
Aucun commentaire:
Enregistrer un commentaire