From 74e30742cc28f8d8e92598c659b7ce96f028afe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D1=80=D0=B8=D0=B3=D0=BE=D1=80=D0=B8=D0=B9=20=D0=A1?= =?UTF-8?q?=D0=B0=D1=84=D1=80=D0=BE=D0=BD=D0=BE=D0=B2?= Date: Sun, 3 Aug 2025 16:50:55 +0000 Subject: [PATCH] Update README.md --- README.md | 92 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 9e2bc5c..5b7e0e2 100644 --- a/README.md +++ b/README.md @@ -208,23 +208,15 @@ futriix:~> get temperature Посмотрим как работают транзакции (создание, откат, коммит) ```sh futriix:~> begin -Transaction 1 started + Transaction 1 started -futriix:tx1:~> insert pressure 1672531200000 1013 -Insert successful + futriix:tx1:~> insert pressure 1672531200000 1013 + Insert successful -futriix:tx1:~> commit -Transaction 1 committed + futriix:tx1:~> commit + Transaction 1 committed ``` - Создадим индекс для поля `age` в таппле user3, а потом удалим его - ```sh - futriix:~> createindex age - Index created on field 'age' - - futriix:~> dropindex age - Index dropped - ``` - +

(К началу)

## Репликация @@ -302,12 +294,12 @@ futunload - Создание бэкапа Пример 1: Создать бэкап в текущей директории ```sh -futunload ./backups/snapshot_2024.fut +futunload ./backups/snapshot_2025.fut Вывод при успехе: text -Backup created successfully at ./backups/snapshot_2024.fut +Backup created successfully at ./backups/snapshot_2025.fut ``` Пример 2: Создать бэкап с абсолютным путём @@ -327,7 +319,7 @@ futload <путь_к_файлу_бэкапа> Пример 1: Восстановить из локального файла bash ```sh -futload ./backups/snapshot_2024.fut +futload ./backups/snapshot_2025.fut Вывод при успехе: text @@ -349,34 +341,68 @@ futload /mnt/backups/prod_db.fut Добавление данных: ```sh +curl -X POST http://127.0.0.1:8081/api/insert \ + -H "Content-Type: application/json" \ + -d '{ + "temperature": [1672531200000, 25.5], + "humidity": [1672531200000, {"value": 60, "unit": "%"}] + }' +``` -curl -X POST http://localhost:8081/api/insert \ - -d '{"user_42": {"name":"John", "age":30}}' +**Ответ в случае успеха:** + +```sh +{"status": "ok"} ``` Получение данных: ```sh -curl -X GET http://localhost:8081/api/get/user_42 - -{"name":"John","age":30} +curl "http://127.0.0.1:8081/api/get/temperature/1672531200000/1672534800000" +``` + +**Ответ в случае успеха:** + +```sh +[ + [1672531200000, 25.5], + [1672531300000, 26.1] +] +``` + +Получение последнего значения: + +```sh +curl "http://127.0.0.1:8081/api/latest/temperature" +``` + +**Ответ в случае успеха:** + +```sh +[1672531300000, 26.1] +``` + +Удаление данных: + +```sh +curl -X DELETE "http://127.0.0.1:8081/api/delete/temperature/1672531200000/1672531300000" +``` +**Ответ в случае успеха:** +```sh +{"status": "ok"} ``` -```sh -Пакетное обновление: -curl -X POST http://localhost:8081/api/update \ - -d '{"user_42": {"age":31}, "product_5": {"price":99}}' - - ``` Пример Python-программы с использованием Http-API: ```sh import requests -BASE_URL = "http://localhost:8081/api" -def set_value(key, value): - requests.post(f"{BASE_URL}/insert", json={key: value}) -def get_value(key): - return requests.get(f"{BASE_URL}/get/{key}").json() +# Добавление данных +requests.post("http://127.0.0.1:8081/api/insert", json={ + "cpu_load": [1672531200000, 0.75] +}) +# Получение данных +response = requests.get("http://127.0.0.1:8081/api/latest/cpu_load") +print(response.json()) # [1672531200000, 0.75] ```