mirror of
https://github.com/Wolvan/poll.horse.git
synced 2024-11-25 06:07:58 +01:00
0545d90c3f
Including to the previous flatfile storage, a new storage for MySQL has been added to store polls in a database. The amount of possible Poll Options has also been reduced to 20.
27 lines
No EOL
748 B
TypeScript
27 lines
No EOL
748 B
TypeScript
"use strict";
|
|
|
|
import Storage from "./Storage";
|
|
import persist from "node-persist";
|
|
import { BackendPoll as Poll } from "./Poll";
|
|
|
|
export default class FlatFileStorage extends Storage {
|
|
#storage: persist.LocalStorage;
|
|
constructor(options: persist.InitOptions) {
|
|
super();
|
|
console.debug("Initiating FlatFileStorage.");
|
|
this.#storage = persist.create(options);
|
|
}
|
|
|
|
async init() {
|
|
await this.#storage.init();
|
|
return this;
|
|
}
|
|
|
|
getItem(key: string): Promise<Poll> {
|
|
return this.#storage.getItem(key);
|
|
}
|
|
|
|
setItem(key: string, value: Poll, options?: persist.DatumOptions): Promise<persist.WriteFileResult> {
|
|
return this.#storage.setItem(key, value, options);
|
|
}
|
|
} |