cawfeecoder / barbr

Example for LinkedIn/Medium series on Go microservices, NATS, and more :)
0 stars 0 forks source link

Add Projection Parameters #2

Closed cawfeecoder closed 5 years ago

cawfeecoder commented 5 years ago

As a system, I want to be able to:

cawfeecoder commented 5 years ago

In order to avoid an extra query when creating a user (i.e. traditional create -> fetch (2 queries)), we take the provided data by the user and merge it with the id that is returned (since we know that no additional data changes take place in the database). This is the only query where projection can not be used. Other queries, such as Delete and Login, do not allow a projection to be provided, but instead automatically project down to the fields they need (thus saving data and preventing data leaks during the transport from Mongo -> us).