You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One quite common use case that I have run into, is to combine two different selectors. This is not as easy at it might first seem, to do Object.assign(selector1, selector2). But rather you must look for any overlap in the keys, and if there are some, use the $and helper. (or always use $and but that can yield large objects)
Would there be an interest of keeping a few utilities somewhere, maybe within this package, or maybe as a separate package, that deals with modifying the objects that goes into mongo-sql?
I'm not sure what would be the most cleanest, just throwing ideas out there :)
The text was updated successfully, but these errors were encountered:
Definitely prefer to keep some utility functions within mongo-sql. I've definitely been in that situation.
Something like mergeConditions(conditionA, conditionB[, conditionC[, ...[, resolverFn]]])
mergeConditions({a: 1},{a: {$gt: 10}},// On column conflict, the resolver function returns a new value// for the conflicting key(column,table,valueA,valueB)=>{return{a: {$or: [valueA,valueB]}}})// => a = 1 or a > 10
I could see common resolvers being used:
mergeConditions({a: 1},{a: {$gt: 10}},mergeConditions.resolvers.or)// => a = 1 or a > 10
One quite common use case that I have run into, is to combine two different selectors. This is not as easy at it might first seem, to do
Object.assign(selector1, selector2)
. But rather you must look for any overlap in the keys, and if there are some, use the$and
helper. (or always use $and but that can yield large objects)Would there be an interest of keeping a few utilities somewhere, maybe within this package, or maybe as a separate package, that deals with modifying the objects that goes into mongo-sql?
I'm not sure what would be the most cleanest, just throwing ideas out there :)
The text was updated successfully, but these errors were encountered: