Model query scopes

Here comes the implementation for #272.

Unit-tested and very simple. I like it.