Closed GhostMayor closed 1 year ago
I like that idea. As the new version doesn't have a filter
method we might want to put it on the query()
function, as this allows to add any URLSearchParameter
to the resource.
Smth like:
o('user').query(filterBuilder.eq('age', 20).and().startswith('name', 'A'))
And the filter builder returns an object like
{
'$filter': 'age eq 20 and startswith(name, 'A')'
}
But how could you combine and/or like this (age eq 20 or age eq 19) and birthyear eq 1986
?
easy and(or(eq('age', 20), eq('age', 19)),eq('birthday',1986))
or or(eq('age', 20), eq('age', 19).and(eq('birthday',1986)))
function returned object wich has methods or. er, and .. etc.
or used toString() get complited query.
I recently had to translate ag-grid's filter model to fit our odata service. It wasn't pretty. I'm not sure that kind code should be inside o.js But a library for building odata filters would be very useful as an opt-in add-on.
Do you think of it as a secondary package? So you wouldn't add it as functionality this lib?
odata-query support added.
What do you think about writing tools for compiling filters as a declarative description ? example: o('User') .filter(tools.eq('age', 20).and().startswith('name', 'A'))