In my company we work with models based on the standard "Active Record", that is, the methods of the model are always referring to the operations of a single record of the database, for example:
Class User {
int id;
string Name;
public Find (id); // SQL / ORM to return the object based on the user's Id;
public Save (); // SQL / ORM to save / update a user
public Delete (); // SQL / ORM to delete a user.
}
// Create the user "John"
Set objUser = new User ();
objUser.Name = "John";
objUser.Save ();
My question is as follows, regarding the entity of the database "User", we have methods that are at table level and not record level, such as a "getAllActiveUsers" method, which returns me an object of query of all active users. This type of situation today, due to a lack of standard ends up in the model ActiveRecord itself, which in my opinion does not make much sense .. Could you tell me what would be the most recommendable / elegant to treat this type of situation? I read something about Gateway and Repository Pattern that might be useful for this, but I wanted to know if anyone else has had this same dilemma and how did they solve it ..
Thank you and sorry for ignorance!