Browse Source

Nc fix: add missing formula docs and link (#7987)

* fix(nc-gui): show view in docs btn from formula suggestion modal only if docs link is present

* fix(nocodb-sdk): add docs link form `REGEX_MATCH` formula

* docs: datetime routines

* docs: add missing links

* fix(nc-gui): AI pr review suggestion

* docs: pr ai review changes

* docs: formula record id

---------

Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/8002/head
Ramesh Mane 8 months ago committed by GitHub
parent
commit
2e132bf16a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      packages/nc-gui/components/smartsheet/column/FormulaOptions.vue
  2. 76
      packages/noco-docs/docs/070.fields/040.field-types/060.formula/040.date-functions.md
  3. 24
      packages/noco-docs/docs/070.fields/040.field-types/060.formula/060.generic-functions.md
  4. 18
      packages/nocodb-sdk/src/lib/formulaHelpers.ts

2
packages/nc-gui/components/smartsheet/column/FormulaOptions.vue

@ -332,7 +332,7 @@ onMounted(() => {
</div> </div>
</div> </div>
<div class="flex flex-row mt-1 mb-3 justify-end pr-3"> <div class="flex flex-row mt-1 mb-3 justify-end pr-3">
<a target="_blank" rel="noopener noreferrer" :href="suggestionPreviewed.docsUrl"> <a v-if="suggestionPreviewed.docsUrl" target="_blank" rel="noopener noreferrer" :href="suggestionPreviewed.docsUrl">
<NcButton type="text" class="!text-gray-400 !hover:text-gray-800 !text-xs" <NcButton type="text" class="!text-gray-400 !hover:text-gray-800 !text-xs"
>View in Docs >View in Docs
<GeneralIcon icon="openInNew" class="ml-1" /> <GeneralIcon icon="openInNew" class="ml-1" />

76
packages/noco-docs/docs/070.fields/040.field-types/060.formula/040.date-functions.md

@ -22,7 +22,7 @@ DATETIME_DIFF("2022/10/14", "2022/10/15", "seconds") => -86400
``` ```
#### Remark #### Remark
This function compares two dates and returns the difference in the specified unit. Positive integers indicate that second date is in the past compared to first, and vice versa for negative values. This function compares two dates and returns the difference in the specified unit. Positive integers indicate that the second date is in the past compared to the first, and vice versa for negative values.
--- ---
@ -94,6 +94,80 @@ Returns the day of the week as an integer between 0 and 6 (inclusive), with Mond
--- ---
## DATESTR
The DATESTR function converts a date or datetime field into a string in "YYYY-MM-DD" format.
#### Syntax
```plaintext
DATESTR(date | datetime)
```
#### Sample
```plaintext
DATESTR('2022-03-14') => 2022-03-14
DATESTR('2022-03-14 12:00:00') => 2022-03-14
```
#### Remark
This function converts a date or datetime field into a string in "YYYY-MM-DD" format, ignoring the time part.
---
## DAY
The DAY function returns the day of the month as an integer.
#### Syntax
```plaintext
DAY(date | datetime)
```
#### Sample
```plaintext
DAY('2022-03-14') => 14
DAY('2022-03-14 12:00:00') => 14
```
#### Remark
This function returns the day of the month as an integer between 1 and 31 (inclusive).
---
## MONTH
The MONTH function returns the month of the year as an integer.
#### Syntax
```plaintext
MONTH(date | datetime)
```
#### Sample
```plaintext
MONTH('2022-03-14') => 3
MONTH('2022-03-14 12:00:00') => 3
```
#### Remark
This function returns the month of the year as an integer between 1 and 12 (inclusive).
---
## HOUR
The HOUR function returns the hour of the day as an integer.
#### Syntax
```plaintext
HOUR(datetime)
```
#### Sample
```plaintext
HOUR('2022-03-14 12:00:00') => 12
```
#### Remark
This function returns the hour of the day as an integer between 0 and 23 (inclusive).
---
## Related Articles ## Related Articles
- [Numeric and Logical Operators](015.operators.md) - [Numeric and Logical Operators](015.operators.md)

24
packages/noco-docs/docs/070.fields/040.field-types/060.formula/060.generic-functions.md

@ -0,0 +1,24 @@
---
title: 'Generic Functions'
description: 'This article explains system functions & miscellaneous functions that can be used in formula fields.'
tags: ['Fields', 'Field types', 'Formula']
keywords: ['Fields', 'Field types', 'Formula', 'Create formula field', 'System functions', 'Miscellaneous functions']
---
# System Functions
## RECORD_ID
The `RECORD_ID` function returns the unique identifier of the record.
#### Syntax
```plaintext
RECORD_ID()
```
#### Sample
```plaintext
RECORD_ID() => 1
```
---

18
packages/nocodb-sdk/src/lib/formulaHelpers.ts

@ -282,6 +282,8 @@ interface FormulaMeta {
export const formulas: Record<string, FormulaMeta> = { export const formulas: Record<string, FormulaMeta> = {
AVG: { AVG: {
docsUrl:
'https://docs.nocodb.com/fields/field-types/formula/numeric-functions#avg',
validation: { validation: {
args: { args: {
min: 1, min: 1,
@ -296,10 +298,10 @@ export const formulas: Record<string, FormulaMeta> = {
'AVG({column1}, {column2}, {column3})', 'AVG({column1}, {column2}, {column3})',
], ],
returnType: FormulaDataTypes.NUMERIC, returnType: FormulaDataTypes.NUMERIC,
docsUrl:
'https://docs.nocodb.com/fields/field-types/formula/numeric-functions#avg',
}, },
ADD: { ADD: {
docsUrl:
'https://docs.nocodb.com/fields/field-types/formula/numeric-functions#add',
validation: { validation: {
args: { args: {
min: 1, min: 1,
@ -314,8 +316,6 @@ export const formulas: Record<string, FormulaMeta> = {
'ADD({column1}, {column2}, {column3})', 'ADD({column1}, {column2}, {column3})',
], ],
returnType: FormulaDataTypes.NUMERIC, returnType: FormulaDataTypes.NUMERIC,
docsUrl:
'https://docs.nocodb.com/fields/field-types/formula/numeric-functions#add',
}, },
DATEADD: { DATEADD: {
docsUrl: docsUrl:
@ -376,6 +376,8 @@ export const formulas: Record<string, FormulaMeta> = {
returnType: FormulaDataTypes.DATE, returnType: FormulaDataTypes.DATE,
}, },
DATESTR: { DATESTR: {
docsUrl:
'https://docs.nocodb.com/fields/field-types/formula/date-functions#datestr',
validation: { validation: {
args: { args: {
rqd: 1, rqd: 1,
@ -387,6 +389,8 @@ export const formulas: Record<string, FormulaMeta> = {
returnType: FormulaDataTypes.STRING, returnType: FormulaDataTypes.STRING,
}, },
DAY: { DAY: {
docsUrl:
'https://docs.nocodb.com/fields/field-types/formula/date-functions#day',
validation: { validation: {
args: { args: {
rqd: 1, rqd: 1,
@ -398,6 +402,8 @@ export const formulas: Record<string, FormulaMeta> = {
returnType: FormulaDataTypes.STRING, returnType: FormulaDataTypes.STRING,
}, },
MONTH: { MONTH: {
docsUrl:
'https://docs.nocodb.com/fields/field-types/formula/date-functions#month',
validation: { validation: {
args: { args: {
rqd: 1, rqd: 1,
@ -409,6 +415,8 @@ export const formulas: Record<string, FormulaMeta> = {
returnType: FormulaDataTypes.STRING, returnType: FormulaDataTypes.STRING,
}, },
HOUR: { HOUR: {
docsUrl:
'https://docs.nocodb.com/fields/field-types/formula/date-functions#hour',
validation: { validation: {
args: { args: {
rqd: 1, rqd: 1,
@ -1171,6 +1179,8 @@ export const formulas: Record<string, FormulaMeta> = {
syntax: 'REGEX_MATCH(string, regex)', syntax: 'REGEX_MATCH(string, regex)',
examples: ['REGEX_MATCH({title}, "abc.*")'], examples: ['REGEX_MATCH({title}, "abc.*")'],
returnType: FormulaDataTypes.NUMERIC, returnType: FormulaDataTypes.NUMERIC,
docsUrl:
'https://docs.nocodb.com/fields/field-types/formula/string-functions#regex_match',
}, },
REGEX_EXTRACT: { REGEX_EXTRACT: {

Loading…
Cancel
Save