jeudi 24 décembre 2020

How to correctly implement the repository pattern?

All examples on the internet have the basic 4 crud methods.

I am really confused how a big system will implement the repository pattern. Let's say I have a user which belongs to groups and has written books.

Sometimes I only need the user data, some times with his books data and sometimes with groups data. Do I implement a method for each of the usecases ?

And how to abstract updates? If I am using MongoDB then I have $inc, $pull and other awesome operators.

How do I actually abstract these types of updates if I need to combine them, for example $set with $inc. Do I need to have a separate method for each usecase of the system ?

Aucun commentaire:

Enregistrer un commentaire