Compare commits
3 Commits
5cf42e538c
...
fc8eb81ffe
Author | SHA1 | Date | |
---|---|---|---|
fc8eb81ffe | |||
8f76a3e59b | |||
45e9dd43e4 |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navy.gif/wrappers",
|
||||
"version": "1.2.2",
|
||||
"version": "1.3.0",
|
||||
"description": "Various wrapper classes I use in my projects",
|
||||
"repository": "https://git.corgi.wtf/Navy.gif/wrappers.git",
|
||||
"author": "Navy.gif",
|
||||
|
@ -15,9 +15,9 @@ type Credentials = {
|
||||
}
|
||||
|
||||
export type MariaOptions = {
|
||||
load: boolean,
|
||||
cluster: PoolClusterConfig,
|
||||
client: PoolConfig,
|
||||
load?: boolean,
|
||||
cluster?: PoolClusterConfig,
|
||||
client?: PoolConfig,
|
||||
credentials: Credentials,
|
||||
loggerOptions?: LoggerClientOptions
|
||||
}
|
||||
|
@ -14,8 +14,9 @@ type Credentials = {
|
||||
|
||||
export type MongoOptions = {
|
||||
credentials: Credentials,
|
||||
loggerOptions: LoggerClientOptions,
|
||||
client: MongoClientOptions
|
||||
loggerOptions?: LoggerClientOptions,
|
||||
client: MongoClientOptions,
|
||||
load?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,6 +91,9 @@ class MongoDB {
|
||||
*/
|
||||
async init () {
|
||||
|
||||
if (this.#config.load)
|
||||
return this.#logger.info('Not loading MongoDB');
|
||||
|
||||
this.#logger.status(`Initializing database connection to ${this.#_client.options.hosts}`);
|
||||
|
||||
await this.#_client.connect();
|
||||
@ -307,17 +311,17 @@ class MongoDB {
|
||||
await this.#db.collection(collection).createIndex(indices);
|
||||
}
|
||||
|
||||
async getKey (key: string, collection = 'memoryStore') {
|
||||
const response = await this.findOne(collection, { key });
|
||||
if (response)
|
||||
return response.value;
|
||||
return null;
|
||||
}
|
||||
// async getKey (key: string, collection = 'memoryStore') {
|
||||
// const response = await this.findOne(collection, { key });
|
||||
// if (response)
|
||||
// return response.value;
|
||||
// return null;
|
||||
// }
|
||||
|
||||
async setKey (key: string, value: object, collection = 'memoryStore') {
|
||||
await this.updateOne(collection, { key }, { value }, true);
|
||||
return value;
|
||||
}
|
||||
// async setKey (key: string, value: object, collection = 'memoryStore') {
|
||||
// await this.updateOne(collection, { key }, { value }, true);
|
||||
// return value;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user