Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails' ActiveRecord-like scopes #384

Open
gfx opened this issue Feb 14, 2017 · 0 comments
Open

Rails' ActiveRecord-like scopes #384

gfx opened this issue Feb 14, 2017 · 0 comments

Comments

@gfx
Copy link
Member

gfx commented Feb 14, 2017

http://guides.rubyonrails.org/active_record_querying.html#scopes

Scoping allows you to specify commonly-used queries which can be referenced as method calls on the association objects or models. With these scopes, you can use every method previously covered such as where, joins and includes. All scope methods will return an

I'm planning something like this:

@Table
public class Todo {
  // ...

  @Column(indexed = true)
  public Date createdAt;

  @RelationMixin
  public static Todo_Relation today(Todo_Relation relation) {
    return relation.createdAtGe(calculateTodayStartedDate());
  }
}

The @RelationMixin injects methods to Todo_Relation:

// generated code!

public class Todo_Relation {

  public Todo_Relation today() {
    return Todo.today(this);
  }

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant