Forum Post: Query Builder

  • Thread starter Thread starter Marian Edu
  • Start date Start date
Status
Not open for further replies.
M

Marian Edu

Guest
trying to come up with some kind of query builder that can help calling select/update/delete queries looking at a fluent syntax what would you guys use to build the filter/where clause? what I’m contemplating right now is something along the line of… query.each(‘customer').where(‘custnum', 10) -> simple query, eq operator as default (each customer where custnum = 10) query.each(‘customer’, ’name,city,address').where(‘balance', ‘>', 100) -> simple query (each customer where balance > 100) query.each(‘customer').where().and(‘balance', ‘>', 100).eq(’country’, ‘USA’).or(’state’, ‘AL’).eq(’state’, ‘AK’).endOr().endAnd() -> each customer where balance > 100 and country = ‘USA’ and (state = ‘AL’ or state = ‘AK’) does this make any sense at all? does simply passing a filter object makes for a better alternative? the only concern there is this can be seen as ‘internal’ and changing the structure later will be impossible without breaking existing code… the structure looks something like this: “filter”: { 'and | or': [ condition, condition, …] | condition := { “field”: value } | { “field”: {“op”: value}} | and | or } thoughts?

Continue reading...
 
Status
Not open for further replies.
Back
Top