Skip to content

Commit

Permalink
feat: ✨ add support for root and params in GROQEvaluate
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Dec 23, 2024
1 parent 61aa64c commit 7a868fe
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/core/src/groq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@ import { parse, evaluate } from "groq-js"
* Loads and applies GROQ transformation to the input data
* @param input
*/
export async function GROQEvaluate(query: string, dataset: any): Promise<any> {
export async function GROQEvaluate(
query: string,
dataset: any,
options?: {
root?: any
params?: Record<string, unknown>
}
): Promise<any> {
if (dataset === undefined) return dataset

const tree = parse(query)
const value = await evaluate(tree, { dataset })
const value = await evaluate(tree, { dataset, ...(options || {}) })
const res = await value.get()
return res
}

0 comments on commit 7a868fe

Please sign in to comment.