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

Feature Idea: Query generator #50

Open
riannucci opened this issue Apr 28, 2016 · 1 comment
Open

Feature Idea: Query generator #50

riannucci opened this issue Apr 28, 2016 · 1 comment

Comments

@riannucci
Copy link
Member

riannucci commented Apr 28, 2016

We could add a tool to generate a per-model typed Query object. So instead of:

q := datastore.NewQuery("Kind").Eq("Property", 1).Lt("OtherThing", "value")

You would have:

/// PropertyEq has type func(...int) *KindQuery
// OtherLt has type func(...string) *KindQuery
q := KindQuery().PropertyEq(1).OtherThingLt("value")

This would avoid pitfalls around runtime type mismatches and typos.

And then you win the world :)

@riannucci
Copy link
Member Author

A possible alternate syntax could look like

// Property() has type *KindQueryProperty
// OtherThing() has type *KindQueryOtherThing
// Both would have Eq, Lt, Gt, Gte, Lte, etc. of the type appropriate for that property

q := KindQuery().Property().Eq(1).OtherThing().Lt("value")

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

No branches or pull requests

1 participant