Update documentation and clients for v1.1.0
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
Documentation updates: - Fix v0.1.0 → v1.1.0 version numbers in en, ru, fa, zh docs - Add missing Window Functions, Multi-Tenant ERP, Supported Keywords sections to ru, fa, zh baraql.md (~105 lines each) - Expand Turkish and Arabic baraql.md (110 → 268 lines) - Expand Turkish and Arabic installation.md (62 → 307 lines) - Add new Bulgarian documentation files (18 new files) Client updates: - Python: Full async/await rewrite with asyncio, request queueing - Rust: Full async/await rewrite with tokio, async examples - Nim: Update README to v1.1.0 - All clients now support async patterns consistently
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
# Потребителски Функции (UDF)
|
||||
|
||||
Разширете BaraQL с персонализирани функции.
|
||||
|
||||
## Употреба
|
||||
|
||||
```nim
|
||||
import barabadb/query/udf
|
||||
|
||||
var reg = newUDFRegistry()
|
||||
|
||||
# Регистриране на стандартна библиотека
|
||||
reg.registerStdlib() # abs, sqrt, pow, lower, upper, len, trim, substr, toString, toInt
|
||||
|
||||
# Персонализирана функция
|
||||
reg.register("greet", @[UDFParam(name: "name", typeName: "str")],
|
||||
"str", proc(args: seq[Value]): Value =
|
||||
return Value(kind: vkString, strVal: "Hello, " & args[0].strVal & "!"))
|
||||
```
|
||||
|
||||
## Функции от Стандартната Библиотека
|
||||
|
||||
| Функция | Описание | Пример |
|
||||
|----------|----------|--------|
|
||||
| `abs(n)` | Абсолютна стойност | `abs(-5)` → 5 |
|
||||
| `sqrt(n)` | Квадратен корен | `sqrt(16)` → 4 |
|
||||
| `pow(n, e)` | Степенуване | `pow(2, 3)` → 8 |
|
||||
| `lower(s)` | Малки букви | `lower('ABC')` → 'abc' |
|
||||
| `upper(s)` | Главни букви | `upper('abc')` → 'ABC' |
|
||||
| `len(s)` | Дължина | `len('hello')` → 5 |
|
||||
| `trim(s)` | Премахване на интервали | `trim(' hello ')` → 'hello' |
|
||||
| `substr(s, start, len)` | Подниз | `substr('hello', 0, 3)` → 'hel' |
|
||||
| `toString(n)` | Конвертиране в низ | `toString(123)` → '123' |
|
||||
| `toInt(s)` | Конвертиране в integer | `toInt('123')` → 123 |
|
||||
|
||||
## Регистриране на Функции
|
||||
|
||||
```nim
|
||||
reg.register(
|
||||
name: "my_function",
|
||||
params: @[
|
||||
UDFParam(name: "arg1", typeName: "str"),
|
||||
UDFParam(name: "arg2", typeName: "int32")
|
||||
],
|
||||
returnType: "str",
|
||||
body: proc(args: seq[Value]): Value =
|
||||
result = Value(kind: vkString, strVal: "")
|
||||
)
|
||||
```
|
||||
|
||||
## Използване на UDF в Заявки
|
||||
|
||||
```sql
|
||||
SELECT greet(name) FROM users;
|
||||
```
|
||||
Reference in New Issue
Block a user