/
dimamir
/
undb
Обзор
Документация
Войти
/
dimamir
/
undb
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/template/src/templates/test.base.json
643 строки
16 KB
nichenqin
feat: add other date formula
08 ноя 2024, 06:57
08 ноя 2024, 06:57
612819b
Код
Авторство
О чём код?
{ "Test": { "tables": { "Table1": { "schema": { "Title": { "id": "title", "type": "string" }, "Ref2": { "id": "ref2", "type": "reference", "option": { "createSymmetricField": true, "foreignTable": { "tableName": "Table2" } } }, "Roll1": { "id": "roll1", "type": "rollup", "option": { "referenceFieldId": "ref2", "rollupFieldId": "title", "fn": "lookup" } }, "Ref22": { "id": "ref22", "type": "reference", "option": { "createSymmetricField": true, "foreignTable": { "tableName": "Table2" } } }, "Count1": { "id": "count1", "type": "number" }, "Count2": { "id": "count2", "type": "currency", "option": { "symbol": "$" } }, "Sum": { "id": "sum", "type": "formula", "option": { "fn": "{{count1}} + {{count2}}" } }, "SumAdd": { "id": "sumadd", "type": "formula", "option": { "fn": "ADD({{count1}}, ADD({{count2}}, {{count1}}))" } }, "SumCounts": { "id": "sumcounts", "type": "formula", "option": { "fn": "SUM({{count1}}, {{count2}})" } }, "SumSum": { "id": "sumsum", "type": "formula", "option": { "fn": "SUM({{sum}}, {{sumadd}})" } }, "Multiply": { "id": "multiply", "type": "formula", "option": { "fn": "MULTIPLY({{count1}}, {{count2}})" } }, "ComplicatedFn": { "id": "complicatedFn", "type": "formula", "option": { "fn": "ADD({{count1}}, MULTIPLY({{count2}}, {{count1}}))" } }, "Concat": { "id": "concat", "type": "formula", "option": { "fn": "CONCAT({{id}}, {{title}}, {{count1}}, {{count2}}, {{complicatedFn}})" } }, "Sum2": { "id": "sum2", "type": "formula", "option": { "fn": "{{count1}} + {{sum}}" } } }, "records": [ { "Title": "1-1", "Ref2": ["1", "2"], "Ref22": ["1", "2"], "Count1": 1, "Count2": 2 }, { "Title": "1-2", "Ref2": ["2"], "Ref22": ["2"], "Count1": 2, "Count2": 3 } ] }, "Table2": { "schema": { "Title": { "id": "title", "type": "string" }, "Ref1": { "id": "ref1", "type": "reference", "option": { "symmetricFieldId": "ref2" } }, "Ref11": { "id": "ref11", "type": "reference", "option": { "symmetricFieldId": "ref22" } }, "T1": { "id": "t1", "type": "rollup", "option": { "referenceFieldId": "ref1", "rollupFieldId": "title", "fn": "lookup" } } }, "records": [ { "id": "1", "Title": "2-1" }, { "id": "2", "Title": "2-2" } ] }, "Formula1": { "fieldsOrder": ["Count1", "Count2", "Count3", "String1", "String2", "Json1"], "schema": { "Count1": { "id": "count1", "type": "number" }, "Count2": { "id": "count2", "type": "number" }, "Count3": { "id": "count3", "type": "number" }, "String1": { "id": "string1", "type": "string" }, "String2": { "id": "string2", "type": "string" }, "Json1": { "id": "json1", "type": "json" }, "IF": { "id": "if", "type": "formula", "option": { "fn": "IF({{count1}} > {{count2}}, ADD({{count1}}, {{count2}}), SUBTRACT({{count1}}, {{count2}}))" } }, "Sum": { "id": "sum", "type": "formula", "option": { "fn": "{{count1}} + {{count2}} + {{count3}}" } }, "Subtract": { "id": "subtract", "type": "formula", "option": { "fn": "{{count1}} - {{count2}}" } }, "Mod": { "id": "mod", "type": "formula", "option": { "fn": "MOD({{count3}}, {{count2}})" } }, "Abs": { "id": "abs", "type": "formula", "option": { "fn": "ABS({{count3}})" } }, "Round": { "id": "round", "type": "formula", "option": { "fn": "ROUND({{count3}})" } }, "Floor": { "id": "floor", "type": "formula", "option": { "fn": "FLOOR({{count3}})" } }, "Ceiling": { "id": "ceiling", "type": "formula", "option": { "fn": "CEILING({{count3}})" } }, "Min1": { "id": "min", "type": "formula", "option": { "fn": "MIN({{count3}}, {{count2}})" } }, "Min2": { "id": "min2", "type": "formula", "option": { "fn": "MIN({{count3}}, {{count1}}, {{count2}})" } }, "Max1": { "id": "max1", "type": "formula", "option": { "fn": "MAX({{count3}}, {{count2}})" } }, "Max2": { "id": "max2", "type": "formula", "option": { "fn": "MAX({{count3}}, {{count1}}, {{count2}})" } }, "Average": { "id": "average", "type": "formula", "option": { "fn": "AVERAGE({{count3}}, {{count1}}, {{count2}})" } }, "Concat": { "id": "concat", "type": "formula", "option": { "fn": "CONCAT({{string1}}, ' ', {{string2}})" } }, "Upper": { "id": "upper", "type": "formula", "option": { "fn": "UPPER({{string1}})" } }, "Lower": { "id": "lower", "type": "formula", "option": { "fn": "LOWER({{string1}})" } }, "Trim": { "id": "trim", "type": "formula", "option": { "fn": "TRIM({{string1}})" } }, "Left": { "id": "left", "type": "formula", "option": { "fn": "LEFT({{string1}}, 3)" } }, "Right": { "id": "right", "type": "formula", "option": { "fn": "RIGHT({{string1}}, 3)" } }, "Mid": { "id": "mid", "type": "formula", "option": { "fn": "MID({{string1}}, 2, 3)" } }, "Greater": { "id": "greater", "type": "formula", "option": { "fn": "{{count1}} > {{count2}}" } }, "And": { "id": "nestedCompare", "type": "formula", "option": { "fn": "({{count1}} > {{count2}}) AND ({{count2}} > {{count3}})" } }, "Or": { "id": "or", "type": "formula", "option": { "fn": "({{count1}} > {{count2}}) OR ({{count2}} > {{count3}})" } }, "NOT": { "id": "not", "type": "formula", "option": { "fn": "NOT ({{count1}} > {{count2}})" } }, "Equal": { "id": "equal", "type": "formula", "option": { "fn": "{{count1}} = {{count2}}" } }, "NotEqual": { "id": "notEqual", "type": "formula", "option": { "fn": "{{count1}} != {{count2}}" } }, "GreaterEqual": { "id": "greaterEqual", "type": "formula", "option": { "fn": "{{count1}} >= {{count2}}" } }, "LessEqual": { "id": "lessEqual", "type": "formula", "option": { "fn": "{{count1}} <= {{count2}}" } }, "Less": { "id": "less", "type": "formula", "option": { "fn": "{{count1}} < {{count2}}" } }, "Len": { "id": "len", "type": "formula", "option": { "fn": "LEN({{string1}})" } }, "Replace": { "id": "replace", "type": "formula", "option": { "fn": "REPLACE({{string1}}, 'llo', {{string2}})" } }, "Search": { "id": "search", "type": "formula", "option": { "fn": "SEARCH({{string1}}, {{string2}})" } }, "Repeat": { "id": "repeat", "type": "formula", "option": { "fn": "REPEAT({{string1}}, 3)" } }, "JsonExtractName": { "id": "jsonExtractName", "type": "formula", "option": { "fn": "JSON_EXTRACT({{json1}}, '$.name')" } }, "AddAutoIncrement": { "id": "addAutoIncrement", "type": "formula", "option": { "fn": "{{count1}} + {{autoIncrement}}" } } }, "records": [ { "Count1": 1, "Count2": 2, "Count3": 3, "String1": "Hello", "String2": "World", "Json1": "{\"name\": \"John\", \"age\": 30, \"city\": \"New York\"}" }, { "Count1": 4, "Count2": 2, "Count3": -3, "String1": " Hello " }, { "Count1": 5, "Count2": 3, "String1": "Hello", "String2": "llo" } ] }, "Formula2": { "schema": { "Date1": { "id": "date1", "type": "date" }, "Date2": { "id": "date2", "type": "date" }, "DateAdd1": { "id": "dateAdd1", "type": "formula", "option": { "fn": "DATE_ADD({{date1}}, 1, 'day')" } }, "DateAdd2": { "id": "dateAdd2", "type": "formula", "option": { "fn": "DATE_ADD({{date1}}, 1, 'month')" } }, "DateAdd3": { "id": "dateAdd3", "type": "formula", "option": { "fn": "DATE_ADD({{date1}}, 1, 'year')" } }, "DateAdd4": { "id": "dateAdd4", "type": "formula", "option": { "fn": "DATE_ADD({{date1}}, 1, 'hour')" } }, "DateAdd5": { "id": "dateAdd5", "type": "formula", "option": { "fn": "DATE_ADD({{date1}}, 1, 'minute')" } }, "DateAdd6": { "id": "dateAdd6", "type": "formula", "option": { "fn": "DATE_ADD({{date1}}, 1, 'second')" } }, "DateSubtract1": { "id": "dateSubtract1", "type": "formula", "option": { "fn": "DATE_SUBTRACT({{date1}}, 1, 'day')" } }, "DateSubtract2": { "id": "dateSubtract2", "type": "formula", "option": { "fn": "DATE_SUBTRACT({{date1}}, 1, 'month')" } }, "DateSubtract3": { "id": "dateSubtract3", "type": "formula", "option": { "fn": "DATE_SUBTRACT({{date1}}, 1, 'year')" } }, "DateSubtract4": { "id": "dateSubtract4", "type": "formula", "option": { "fn": "DATE_SUBTRACT({{date1}}, 1, 'hour')" } }, "DateSubtract5": { "id": "dateSubtract5", "type": "formula", "option": { "fn": "DATE_SUBTRACT({{date1}}, 1, 'minute')" } }, "DateSubtract6": { "id": "dateSubtract6", "type": "formula", "option": { "fn": "DATE_SUBTRACT({{date1}}, 1, 'second')" } }, "DateDiff1": { "id": "dateDiff1", "type": "formula", "option": { "fn": "DATE_DIFF({{date1}}, {{date2}}, 'day')" } }, "DateDiff2": { "id": "dateDiff2", "type": "formula", "option": { "fn": "DATE_DIFF({{date1}}, {{date2}}, 'month')" } }, "DateDiff3": { "id": "dateDiff3", "type": "formula", "option": { "fn": "DATE_DIFF({{date1}}, {{date2}}, 'year')" } }, "Year": { "id": "year", "type": "formula", "option": { "fn": "YEAR({{date1}})" } }, "Month": { "id": "month", "type": "formula", "option": { "fn": "MONTH({{date1}})" } }, "Day": { "id": "day", "type": "formula", "option": { "fn": "DAY({{date1}})" } }, "Hour": { "id": "hour", "type": "formula", "option": { "fn": "HOUR({{date1}})" } }, "Minute": { "id": "minute", "type": "formula", "option": { "fn": "MINUTE({{date1}})" } }, "Second": { "id": "second", "type": "formula", "option": { "fn": "SECOND({{date1}})" } }, "Weekday": { "id": "weekday", "type": "formula", "option": { "fn": "WEEKDAY({{date1}})" } } }, "records": [ { "Date1": "2024-01-01", "Date2": "2024-01-02" }, { "Date1": "2024-01-01", "Date2": "2024-02-01" }, { "Date1": "2024-01-01", "Date2": "2025-01-01" } ] } } } }