2024-09-26 23:16:12 +02:00
|
|
|
# ParamDB
|
|
|
|
|
2024-09-27 00:15:35 +02:00
|
|
|
ParamDB is a key-value store that is time-aware. Multiple values can be assigned to each
|
|
|
|
key with unique validity ranges. It can be used to feed static information that varies
|
|
|
|
with time to templates or to serve news.
|
|
|
|
|
|
|
|
## Introduction
|
|
|
|
|
|
|
|
There are situations where you need data to slap into a template, and the data may vary
|
|
|
|
over time.
|
|
|
|
|
|
|
|
* Sending alert e-mails including contact information for the curent support techs.
|
|
|
|
* Seasonal greetings in automatically generated content.
|
|
|
|
|
|
|
|
ParamDB solves this problem by serving collections of keys over HTTP. A collection can
|
|
|
|
contain any number of keys, and a key can contain any number of values.
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
2024-09-26 23:16:12 +02:00
|
|
|
* Values are serialized, so arrays and objects can be stored and restored.
|
|
|
|
* Not intended to be running as a public service, so there is no authentication, for now.
|
|
|
|
* Last value that matches is returned.
|
|
|
|
|
2024-09-27 00:15:35 +02:00
|
|
|
### Future
|
2024-09-26 23:16:12 +02:00
|
|
|
|
|
|
|
* Metadata; store with key "meta" in value set post call, returned under a "meta" key in the
|
|
|
|
result list.
|
|
|
|
|
|
|
|
## Using
|
|
|
|
|
|
|
|
### Store values
|
|
|
|
|
|
|
|
```json
|
|
|
|
POST /businessinfo
|
|
|
|
Content-Type: application/json
|
|
|
|
|
2024-09-27 00:15:35 +02:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"openhours": {
|
|
|
|
"value": "Mo-Fr 09-17, Sa-Su 12-02",
|
|
|
|
"valid": {
|
|
|
|
"from": "2024-10-01 00:00:00 +02:00",
|
|
|
|
"until": "2024-10-07 23:59:59 +02:00"
|
|
|
|
}
|
2024-09-26 23:16:12 +02:00
|
|
|
}
|
|
|
|
}
|
2024-09-27 00:15:35 +02:00
|
|
|
]
|
2024-09-26 23:16:12 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
### Retrieve current values
|
|
|
|
|
|
|
|
```json
|
|
|
|
GET /businessinfo
|
|
|
|
|
|
|
|
{
|
|
|
|
"openhours": "Mo-Fr 09-17, Sa-Su 10-01"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Query params:
|
|
|
|
|
|
|
|
* `date=` - override date (default is now) in the format "Y-m-d H:i:s P"
|
|
|
|
|
|
|
|
### Retrieve all values
|
|
|
|
|
|
|
|
```json
|
|
|
|
GET /businessinfo/all
|
|
|
|
|
|
|
|
{
|
2024-09-27 00:15:35 +02:00
|
|
|
"openhours": [
|
|
|
|
{
|
|
|
|
"id": 13,
|
|
|
|
"value": "Mo-Fr 09-17, Sa-Su 10-01"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"id": 19,
|
|
|
|
"value": "Mo-Fr 09-17, Sa-Su 12-02",
|
|
|
|
"valid": {
|
|
|
|
"from": "2024-10-01 00:00:00 +02:00",
|
|
|
|
"until": "2024-10-07 23:59:59 +02:00"
|
2024-09-26 23:16:12 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Query params:
|
|
|
|
|
|
|
|
* `only=` - comma-separated list of keys to match
|
|
|
|
|
|
|
|
|
|
|
|
### Delete value
|
|
|
|
|
|
|
|
Delete by posting an array of IDs to delete.
|
|
|
|
|
|
|
|
```json
|
|
|
|
POST /businessinfo/delete
|
|
|
|
Content-Type: application/json
|
|
|
|
|
|
|
|
[ 19 ]
|
|
|
|
```
|
|
|
|
|
|
|
|
### Update a value
|
|
|
|
|
|
|
|
Update by including an existing id with the set request.
|
|
|
|
|
|
|
|
```json
|
|
|
|
POST /businessinfo
|
|
|
|
Content-Type: application/json
|
|
|
|
|
|
|
|
{
|
|
|
|
"openhours": {
|
|
|
|
"id": 19,
|
|
|
|
"value": "Mo-Fr 09-17, Sa-Su 12-03",
|
|
|
|
"valid": {
|
|
|
|
"from": "2024-10-01 00:00:00 +02:00",
|
|
|
|
"until": "2024-10-07 23:59:59 +02:00"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|