Skip to content

Commit

Permalink
Add dateRangeSumField function to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubknejzlik committed Sep 6, 2024
1 parent 36a5a27 commit 4c9fbfc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/stories/3_Function.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ Execute logic based on conditions:

<QueryPreview code={`Fn.if(Cond.equal('status', 'active'), 'Yes', 'No');`} />

### Advanced functions

**DateRange sum field**

<QueryPreview
code={`Fn.dateRangeSumField({dateColumn:"date",valueColumn:"amount",dateFrom:dayjs().startOf('year'),dateTo:dayjs().endOf('month')})`}
/>

## Advanced Usage

Combining functions to create complex expressions:
Expand Down
2 changes: 2 additions & 0 deletions src/stories/QueryPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { themes } from "prism-react-renderer";
import React, { useState } from "react";
import { LiveEditor, LiveError, LivePreview, LiveProvider } from "react-live";
import * as components from "../index";
import dayjs from "dayjs";

interface QueryPreviewProps {
code: string;
Expand All @@ -17,6 +18,7 @@ export const QueryPreview = ({ code }: QueryPreviewProps) => {
code={`const query = ${state.code};\nrender(<>{query.toSQL(Q.flavors.mysql)}</>)`}
scope={{
...components,
dayjs,
}}
noInline={true}
>
Expand Down

0 comments on commit 4c9fbfc

Please sign in to comment.