@valkyriestudios/mongo
Version:
MongoDB Adapter Library
57 lines (56 loc) • 1.34 kB
TypeScript
/**
* MongoDB Protocols
*
* https://www.mongodb.com/docs/manual/reference/connection-string/#std-label-connections-standard-connection-string-format
* https://www.mongodb.com/docs/manual/reference/connection-string/#std-label-connections-dns-seedlist
*/
export declare enum Protocols {
STANDARD = "mongodb",
SRV = "mongodb+srv"
}
export type Protocol = `${Protocols}`;
/**
* MongoDB Read Preferences: How we want to balance our load
*
* https://www.mongodb.com/docs/manual/core/read-preference/
*/
export declare enum ReadPreferences {
PRIMARY = "primary",
PRIMARY_PREFERRED = "primaryPreferred",
SECONDARY = "secondary",
SECONDARY_PREFERRED = "secondaryPreferred",
NEAREST = "nearest"
}
export type ReadPreference = `${ReadPreferences}`;
/**
* LogLevel enumeration
*/
export declare enum LogLevel {
DEBUG = "debug",
INFO = "info",
WARN = "warn",
ERROR = "error"
}
/**
* Types of Log Object shapes
*/
export type LogObject = {
level: LogLevel.DEBUG | LogLevel.INFO | LogLevel.WARN;
fn: string;
msg: string;
data?: {
[key: string]: unknown;
};
} | {
level: LogLevel.ERROR;
fn: string;
msg: string;
err: Error;
data?: {
[key: string]: unknown;
};
};
/**
* Logger Function type
*/
export type LogFn = (log: LogObject) => void;