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

Implement Query API #2

Open
Morgul opened this issue Apr 14, 2013 · 3 comments
Open

Implement Query API #2

Morgul opened this issue Apr 14, 2013 · 3 comments

Comments

@Morgul
Copy link
Owner

Morgul commented Apr 14, 2013

Implement a query api, inspired by django's query api.

Basically, how I would like this to work is like this:

dustbin.query({someKey: "valueToMatch", someOtherKey: "someOtherValueToMatch"});

We can support the field api from django like this:

dustbin.query({someKey__lt: 5, someOtherKey__contains: "partial string"});

Alternatively, we could do this using a jugglingdb like api:

dustbin.query({lessThan: {someKey: 5}, contains: {someOtherKey: "partial string"}});

I'm not sure which I like better.

@Morgul
Copy link
Owner Author

Morgul commented Apr 14, 2013

This was partially implemented in 6f575b7.

@lordnull
Copy link
Collaborator

I refer you to issue #1 . If the browser supports map and filter natively, this does not look like a particularly useful set of features.

dustbin.query('bucket').filter(function(obj) { return obj.someKey < 5; });

var ltFive = function(obj){
    return obj.someKey < 5;
}

var containGoober = function(obj){
    return obj.someOtherKey.match("goober");
}

dustbin.query('bucket').filter(ltFive).filter(containGoober);
ducstbin.query('bucket').filter(function(obj){
    return ltFive(obj) && containGoober(obj);
});

@Morgul
Copy link
Owner Author

Morgul commented Apr 16, 2013

As per issue #1, support for this seems near universal. Unless there's any reason to make things easier, all that needs to be done, really, is documentation.

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

2 participants