declex icon indicating copy to clipboard operation
declex copied to clipboard

Actions for models

Open smaugho opened this issue 7 years ago • 0 comments

Every models should have an action to instantiate it and make complex operations over it:

Ex.

@UseModel
public class User {
    String firstName;
    String lastName;

    String email;
}

Instantiante an user:

    User user = $User().firstName("Bob")
                       .lastName("River")
                       .email("[email protected]")
                       .get();

Queries

The queries mechanism should be embedded in the action for the models, so:

    User user = $User().query("firstName='Bob'").get();
    List<User> user = $User().query("firstName='%B'").list();

This is very important to decouple the internal used ORM (ActiveAndroid, Realm or other) with the queries mechanism.

smaugho avatar Mar 13 '17 17:03 smaugho