Last active
December 30, 2019 14:52
-
-
Save WimJongeneel/41cafea1e9840d2fc694189b01077b8d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const odata = <T>(name: string, baseuri = '/odata'): IQueryable<T> => { | |
const exprs: Expr<T>[] = [] | |
return { | |
where(e) { | |
exprs.push(e(builder()).getExpr()) | |
return this | |
}, | |
toArray: async () => { | |
const res = await fetch(`${baseuri}/${name}?$filter=${exprs.map(compileOdata).join(' and ')}`) | |
const json = await res.json() | |
return json.value | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment