-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
388 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const base: typeof import("./source/base"); | ||
export const database: typeof import("./source/index"); | ||
export const HiveErr: typeof import("./source/err"); | ||
export const schema: (connection: any, name: any) => any; | ||
export const util: typeof import("./source/util"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
export = Base; | ||
declare class Base extends EventEmitter { | ||
/** | ||
*Mongoose connection base. | ||
* @param {string} mongodbURL Mongodb Database URL. | ||
* @param {object} connectionOptions Mongodb connection options | ||
*/ | ||
constructor(mongodbURL: string, connectionOptions?: object); | ||
/** | ||
* Mongoose connection options | ||
* @type {ConnectionOptions} | ||
*/ | ||
options: any; | ||
/** | ||
* Returns mongodb connection | ||
* @type {MongooseConnection} | ||
*/ | ||
connection: any; | ||
/** | ||
* Timestamp when database became ready | ||
* @type {Date} | ||
*/ | ||
readyAt: Date; | ||
/** | ||
* Creates mongodb connection | ||
* @returns {MongooseConnection} | ||
* @ignore | ||
*/ | ||
_create(url: any): any; | ||
dbURL: string; | ||
/** | ||
* Destroys database | ||
* @ignore | ||
*/ | ||
_destroyDatabase(): void; | ||
/** | ||
* Current database url | ||
* @type {string} | ||
*/ | ||
get url(): string; | ||
/** | ||
* Returns database connection state | ||
* @type {("DISCONNECTED"|"CONNECTED"|"CONNECTING"|"DISCONNECTING")} | ||
*/ | ||
get state(): "DISCONNECTED" | "CONNECTED" | "CONNECTING" | "DISCONNECTING"; | ||
} | ||
import EventEmitter_1 = require("events"); | ||
import EventEmitter = EventEmitter_1.EventEmitter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export = HiveErr; | ||
declare class HiveErr extends Error { | ||
constructor(message: any, name?: any); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
export = database; | ||
declare class database extends Base { | ||
/** | ||
* @param {string} | ||
* @param {string} | ||
* @param {object} | ||
*/ | ||
constructor(mongodbURL: any, name: any, connectionOptions?: {}); | ||
/** | ||
* @type {MongooseDocument} | ||
*/ | ||
schema: any; | ||
/** | ||
* @param {string} key | ||
* @param {any} value | ||
* @returns {Promise<any>} | ||
*/ | ||
init(key: string, value: any): Promise<any>; | ||
/** | ||
* @param {string} key | ||
*/ | ||
del(key: string): Promise<boolean>; | ||
/** | ||
* @param {string} key | ||
*/ | ||
exists(key: string): Promise<boolean>; | ||
/** | ||
* @param {string} key | ||
*/ | ||
has(key: string): Promise<boolean>; | ||
/** | ||
* @param {string} key | ||
*/ | ||
get(key: string): Promise<any>; | ||
/** | ||
* @param {string} key | ||
*/ | ||
fetch(key: string): Promise<any>; | ||
/** | ||
* @typedef {object} Data | ||
* @property {string} ID | ||
* @property {any} data | ||
*/ | ||
/** | ||
* @param {number} limit | ||
*/ | ||
fetchArray(limit?: number): Promise<any>; | ||
getArray(limit: any): Promise<any>; | ||
/** | ||
* @param {number} limit | ||
*/ | ||
fetchAll(limit: number): Promise<any>; | ||
delAll(): Promise<boolean>; | ||
/** | ||
* @param {string} key | ||
* @param {string} operator | ||
* @param {number} value | ||
*/ | ||
math(key: string, operator: string, value: number): Promise<any>; | ||
/** | ||
* @param {string} key | ||
* @param {number} Value | ||
*/ | ||
add(key: string, value: any): Promise<any>; | ||
/** | ||
* @param {string} key | ||
* @param {number} value | ||
*/ | ||
subtract(key: string, value: number): Promise<any>; | ||
/** | ||
* @type {number} | ||
*/ | ||
get uptime(): number; | ||
/** | ||
* @param {string} fileName | ||
* @param {string} path | ||
*/ | ||
export(fileName?: string, path?: string): Promise<any>; | ||
/** | ||
* @param {Array} data | ||
* @param {object} ops | ||
* @param {boolean} | ||
* @param {boolean} | ||
*/ | ||
import(data?: any[], ops?: object): Promise<any>; | ||
disconnect(): void; | ||
connect(url: any): any; | ||
get name(): any; | ||
_read(): Promise<number>; | ||
_write(): Promise<number>; | ||
/** | ||
* @typedef {object} DatabaseLatency | ||
* @property {number} read Read latency | ||
* @property {number} write Write latency | ||
* @property {number} average Average latency | ||
*/ | ||
fetchLatency(): Promise<{ | ||
read: number; | ||
write: number; | ||
average: number; | ||
}>; | ||
ping(): Promise<{ | ||
read: number; | ||
write: number; | ||
average: number; | ||
}>; | ||
/** | ||
* @param {string} key | ||
* @param {object} ops | ||
*/ | ||
startsWith(key: string, ops: object): Promise<any[]>; | ||
/** | ||
* Resolves data type | ||
* @param {string} key key | ||
* @example console.log(await db.type("foo")); | ||
* @returns {Promise<"string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "array">} | ||
*/ | ||
datatype(key: string): Promise<"string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "array">; | ||
/** | ||
* Returns array of the keys | ||
* @example const keys = await db.keyarray(); | ||
* console.log(keys); | ||
* @returns {Promise<string[]>} | ||
*/ | ||
keyArray(): Promise<string[]>; | ||
/** | ||
* Returns array of the values | ||
* @example const data = await db.valueArray(); | ||
* console.log(data); | ||
* @returns {Promise<any[]>} | ||
*/ | ||
valueArray(): Promise<any[]>; | ||
/** | ||
* Pushes an item into array | ||
* @param {string} key key | ||
* @param {any|any[]} value Value to push | ||
* @example db.push("users", "John"); // -> ["John"] | ||
* db.push("users", ["Milo", "Simon", "Kyle"]); // -> ["John", "Milo", "Simon", "Kyle"] | ||
* @returns {Promise<any>} | ||
*/ | ||
push(key: string, value: any | any[]): Promise<any>; | ||
/** | ||
* Removes an item from array | ||
* @param {string} key key | ||
* @param {any|any[]} value item to remove | ||
* @param {boolean} [multiple=true] if it should pull multiple items. Defaults to `true`. | ||
* <warn>Currently, you can use `multiple` with `non array` pulls only.</warn> | ||
* @example db.pull("users", "John"); // -> ["Milo", "Simon", "Kyle"] | ||
* db.pull("users", ["Milo", "Simon"]); // -> ["Kyle"] | ||
* @returns {Promise<any>} | ||
*/ | ||
delFromArray(key: string, value: any | any[], multiple?: boolean): Promise<any>; | ||
/** | ||
* Returns entries count of current model | ||
* @returns {Promise<number>} | ||
* @example const entries = await db.entries(); | ||
* console.log(`There are total ${entries} entries!`); | ||
*/ | ||
entries(): Promise<number>; | ||
/** | ||
* Returns raw data from current model | ||
* @param {object} params Search params | ||
* @returns {Promise<MongooseDocument>} | ||
* @example const raw = await db.raw(); | ||
* console.log(raw); | ||
*/ | ||
raw(params: object): Promise<any>; | ||
/** | ||
* Returns random entry from the database | ||
* @param {number} n Number entries to return | ||
* @returns {Promise<any[]>} | ||
* @example const random = await db.random(); | ||
* console.log(random); | ||
*/ | ||
random(n?: number): Promise<any[]>; | ||
/** | ||
* This method acts like `quick.db#table`. It will return new instance of itself. | ||
* @param {string} name Model name | ||
* @returns {Database} | ||
*/ | ||
table(name: string): any; | ||
/** | ||
* This method exports **QuickMongo** data to **Quick.db** | ||
* @param {any} quickdb Quick.db instance | ||
* @returns {Promise<any[]>} | ||
* @example const data = await db.exportToQuickDB(quickdb); | ||
*/ | ||
/** | ||
* Returns **QuickMongo Util** | ||
* @example const parsed = db.utils.parseKey("foo.bar"); | ||
* console.log(parsed); | ||
* @type {Util} | ||
*/ | ||
get utils(): Util; | ||
/** | ||
* Updates current model and uses new one | ||
* @param {string} name model name to use | ||
* @returns {MongooseDocument} | ||
*/ | ||
updateModel(name: string): any; | ||
/** | ||
* Allows you to eval code using `this` keyword. | ||
* @param {string} code | ||
*/ | ||
_eval(code: string): any; | ||
} | ||
declare namespace database { | ||
export { Data }; | ||
} | ||
import Base = require("./base"); | ||
import Util = require("./util"); | ||
type Data = { | ||
ID: string; | ||
data: any; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare function _exports(connection: any, name: any): any; | ||
export = _exports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
export = Util; | ||
declare class Util { | ||
/** | ||
* Returns true if provided key is valid | ||
* @param {any} str Anything to test | ||
* @returns {boolean} | ||
*/ | ||
static isKey(str: any): boolean; | ||
/** | ||
* Returns true if the given data is valid | ||
* @param {any} data Any data | ||
* @returns {boolean} | ||
*/ | ||
static isValue(data: any): boolean; | ||
/** | ||
* @typedef {object} KEY | ||
* @property {string | undefined} key Parsed Key | ||
* @property {string | undefined} target Parsed target | ||
*/ | ||
/** | ||
* Returns target & key from the given string (quickdb style) | ||
* @param {string} key key to parse | ||
* @example Util.parseKey("myitem.items"); | ||
* // -> { key: "myitems", target: "items" } | ||
* @returns {KEY} | ||
*/ | ||
static parseKey(key: string): KEY; | ||
/** | ||
* Sort data | ||
* @param {string} key Key | ||
* @param {Array} data Data | ||
* @param {object} ops options | ||
* @example Util.sort("user_", {...}, { sort: ".data" }); | ||
* @returns {any[]} | ||
*/ | ||
static sort(key: string, data: any[], ops: object): any[]; | ||
/** | ||
* Data resolver | ||
* @param {string} key Data key | ||
* @param {any} data Data | ||
* @param {any} value value | ||
* @example Util.setData("user.items", {...}, ["pen"]); | ||
* @returns {any} | ||
*/ | ||
static setData(key: string, data: any, value: any): any; | ||
/** | ||
* Data resolver | ||
* @param {string} key Data key | ||
* @param {any} data Data | ||
* @param {any} value value | ||
* @example Util.unsetData("user.items", {...}); | ||
* @returns {any} | ||
*/ | ||
static unsetData(key: string, data: any): any; | ||
/** | ||
* Data resolver | ||
* @param {string} key Key | ||
* @param {any} data Data | ||
* @example Util.getData("user.items", {...}); | ||
* @returns {any} | ||
*/ | ||
static getData(key: string, data: any): any; | ||
} | ||
declare namespace Util { | ||
export { KEY }; | ||
} | ||
type KEY = { | ||
/** | ||
* Parsed Key | ||
*/ | ||
key: string | undefined; | ||
/** | ||
* Parsed target | ||
*/ | ||
target: string | undefined; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Pool, PoolConfig, QueryResult } from "pg"; | ||
export interface PostgresOptions { | ||
schema: string; | ||
} | ||
export declare class Postgres { | ||
pool: Pool; | ||
options: PostgresOptions; | ||
constructor(config: PoolConfig, options?: PostgresOptions); | ||
fetchArray(): Promise<any>; | ||
exists(key: string): Promise<boolean>; | ||
init(key: string, val: any): Promise<boolean>; | ||
get(key: string): Promise<any>; | ||
delete(key: string): Promise<boolean>; | ||
push(key: string, element: any): Promise<boolean>; | ||
search(query: string, data?: Array<any>): Promise<QueryResult>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Postgres, PostgresOptions } from './index'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare function _exports(db: any, params: any, options: any): any; | ||
export = _exports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
declare function _exports(db: any, params: any, options: any): { | ||
ID: any; | ||
data: any; | ||
}[]; | ||
export = _exports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare function _exports(db: any, params: any, options: any): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"; | ||
export = _exports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare function _exports(db: any, params: any, options: any): boolean; | ||
export = _exports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare function _exports(db: any, params: any, options: any): any; | ||
export = _exports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare function _exports(db: any, params: any, options: any): boolean; | ||
export = _exports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare function _exports(db: any, params: any, options: any): any; | ||
export = _exports; |
Oops, something went wrong.