returning specific data
Opened this issue · 1 comments
First of all, thank you very much for sharing your work. It's amazing! Let's get rid of all the nasty foreach
loops! :)
I was wondering, how difficult would it be, to return specific fields, instead of entire matched arrays.
Let's say I am looking in an array of invoices, for all with status "done"
s.matchArray(database.invoices,{"status":"done"})
rather then returning all of the invoice data, I would need only value
parameter. I don't think this is currently possible, right?
thank you very much for sharing your work. It's amazing!
Thanks. I try to open source as much as clients will let me when working on things. Anything that is necessary but not value-add to a company is better in the open.
I would need only value parameter. I don't think this is currently possible, right?
Not with the current implementation, but it doesn't look terribly difficult.
Let's use this as a discussion starting point. What would it look like, and how would it work?
matchObject
- irrelevant, it only returns a boolean if it matches or notmatchField
- irrelevant, it only returns a boolean if it matches or notmatchArray
- this is where it matters
matchArray
always returns an array of objects. So are we talking that it would return an array with just a subset of the fields?
e.g.
var list = [{name:"John",age:25, city: "London"},{name:"Jill",age:30, city: "Tel Aviv"}];
matches = s.matchArray(list,{name:"John"}); // returns [{name:"John",age:25, city: "London"}]
Then the variant would be:
var list = [{name:"John",age:25, city: "London"},{name:"Jill",age:30, city: "Tel Aviv"}];
matches = s.matchArray(list,{name:"John"}, ["name"]); // returns [{name:"John"}]
Something like that?