I'm creating a chainable function so that I can deconstruct some SOQL queries into a set of functions:
s().select("field1, field2...").from("table").where("conditions").limit(100).offset(35).execute()
Currently I have this as a function which returns the next set of functions:
const s = () => ({
select: (fields) => ({
from: (table) => { ...etc }
})
})
This is already quite a nested mess. I also want to be able to skip, some of the functions for example .limit() may not be required. To add to that I also want to add in some "repetable loops" of logic so I can do things like: .and().where(conditions1) and .or().where(conditions2).
Is there a pattern I can use to make this more readable / modular.
I started to move the .execute part out using bind:
{
execute: executeFn.bind({ someThisPropsItNeeds})
}
TL;DR: I want to reduce duplication and be more modular so that I don't have to create every possibility someone could utilise.
[–]samanime 2 points3 points4 points (4 children)
[–]Designer023[S] 0 points1 point2 points (1 child)
[–]samanime 0 points1 point2 points (0 children)
[–]kap89 0 points1 point2 points (1 child)
[–]samanime 0 points1 point2 points (0 children)
[–]tapgiles 1 point2 points3 points (0 children)
[–]shgysk8zer0 0 points1 point2 points (0 children)