1
0
Fork 0
mirror of https://github.com/SunRed/haste-server.git synced 2025-09-05 21:10:16 +02:00

Rewritten postgresql document store

This is experimental as there are couple issues with attemting to set duplicate keys and connecting on startup, but it's working regardless of those issues.\nMaybe I can look into solving those later if needed
This commit is contained in:
zneix 2020-09-03 19:24:34 +02:00
parent e3e45bee3c
commit 7d476a668e
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 911916E0523B22F6
5 changed files with 93 additions and 196 deletions

View file

@ -87,8 +87,32 @@ Check [documentation](https://mongodb.github.io/node-mongodb-native/3.5/api/Mong
## Postgres
Not rewritten yet, to be filled in
Requires npm package (Tested on v8.3.3):
```bash
npm install pg
```
You will have to create the database and add a table named `entries`. It can be easily done with the following query:
`CREATE TABLE entries (id SERIAL PRIMARY KEY, key VARCHAR(255) NOT NULL, value TEXT NOT NULL, expiration INT, UNIQUE(key));`
Properties in `clientOptions` are optimal defaults and should be sufficient to run haste, however more detailed explanation for them can be found in pg package [documentation](https://node-postgres.com/api/client).
Expiration property in config can be changed to a value in seconds after which entries will not be served.
```json
{
"type": "postgres",
"expire": 0,
"clientOptions": {
"host": "localhost",
"port": 5432,
"user": "username",
"password": "password",
"database": "haste"
}
}
```
## Redis