4
In my company we work with models based on the "Active Record" standard, that is, the model methods are always related to the operations of a unique database record, 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 the following, in relation to the entity of the "User" database, we have methods that are at table level and not of record, as for example a method "getAllActiveUsers", which returns me a query object of all active users. This kind of situation today, for a lack of pattern ends up staying in the Activerecord model itself, which in my opinion does not make much sense.. Could you tell me what would be the most recommendable/elegant to address this kind of situation? I read something about Gateway and Repository Pattern that might be useful for this, but I was wondering if anyone had this same dilemma and how did to solve..
Thank you and sorry for the ignorance!