Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@e-mc/db

Package Overview
Dependencies
Maintainers
0
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@e-mc/db

DB modules for E-mc.

  • 0.8.16
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
26
decreased by-18.75%
Maintainers
0
Weekly downloads
 
Created
Source

@e-mc/db

  • NodeJS 14
  • ES2019

General Usage

  • Read the Docs

Interface

import type { DbDataSource } from "./squared";

import type { IHost } from "./index";
import type { ClientDbConstructor, IClientDb } from "./core";
import type { DB_TYPE, SQL_COMMAND, BatchQueryResult, ExecuteBatchQueryOptions, ExecuteQueryOptions, HandleFailOptions, PoolConfig, ProcessRowsOptions, QueryResult } from "./db";
import type { DbCoerceSettings, DbModule, DbSourceOptions } from "./settings";

import type { SecureContextOptions } from "tls";

interface IDb extends IClientDb<IHost, DbModule, DbDataSource, DbSourceOptions, DbCoerceSettings> {
    setCredential(item: DbDataSource): Promise<void>;
    getCredential(item: DbDataSource): Record<string | number | symbol, unknown>;
    hasSource(source: string, ...type: number[]): boolean;
    applyCommand(...items: DbDataSource[]): void;
    executeQuery(item: DbDataSource, sessionKey: string): Promise<QueryResult>;
    executeQuery(item: DbDataSource, options?: ExecuteQueryOptions | string): Promise<QueryResult>;
    executeBatchQuery(batch: DbDataSource[], sessionKey: string, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
    executeBatchQuery(batch: DbDataSource[], options?: ExecuteBatchQueryOptions | string, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
    processRows(batch: DbDataSource[], tasks: Promise<QueryResult | null>[], parallel: boolean): Promise<BatchQueryResult>;
    processRows(batch: DbDataSource[], tasks: Promise<QueryResult | null>[], options?: ProcessRowsOptions, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
    handleFail(err: unknown, item: DbDataSource, options?: HandleFailOptions): boolean;
    readTLSCert(value: unknown, cache?: boolean): string;
    readTLSConfig(options: SecureContextOptions, cache?: boolean): void;
    settingsOf(source: string, name: keyof Omit<DbSourceOptions, "coerce">): unknown;
    settingsOf(source: string, name: "coerce", component: keyof DbCoerceSettings): unknown;
    settingsKey(source: string, name: keyof Omit<DbSourceOptions, "coerce">): unknown;
    settingsKey(source: string, name: "coerce", component: keyof DbCoerceSettings): unknown;
    getPoolConfig(source: string, uuidKey?: string): Required<PoolConfig> | undefined;
    get sourceType(): DB_TYPE;
    get commandType(): SQL_COMMAND;
}

interface DbConstructor extends ClientDbConstructor<IHost> {
    setPoolConfig(value: Record<string, PoolConfig>): void;
    getPoolConfig(source: string): Required<PoolConfig> | undefined;
    readonly prototype: IDb;
    new(module?: DbModule, database?: DbDataSource[], ...args: unknown[]): IDb;
}

interface IDbSourceClient {
    DB_SOURCE_NAME: string;
    DB_SOURCE_CLIENT: boolean;
    DB_SOURCE_TYPE: number;
    setCredential(this: IDb, item: DbDataSource): Promise<void>;
    executeQuery(this: IDb, item: DbDataSource, options?: ExecuteQueryOptions | string): Promise<QueryResult>;
    executeBatchQuery(this: IDb, batch: DbDataSource[], options?: ExecuteBatchQueryOptions | string, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
    checkTimeout?(this: IDbSourceClient, value: number, limit?: number): Promise<number>;
}

interface IDbPool {
    client: unknown;
    lastAccessed: number;
    success: number;
    failed: number;
    poolKey: string;
    uuidKey: AuthValue | null;
    add(item: DbDataSource, uuidKey?: string): this;
    has(item: DbDataSource): boolean;
    getConnection(): Promise<unknown>;
    remove(): void;
    detach(force?: boolean): Promise<void>;
    close(): Promise<void>;
    isIdle(timeout: number): boolean;
    isEmpty(): boolean;
    set connected(value: boolean);
    get persist(): boolean;
    get closed(): boolean;
    get closeable(): boolean;
    set parent(value: Record<string, IDbPool>);
}

interface DbPoolConstructor {
    findKey(pools: Record<string, IDbPool>, uuidKey: unknown, poolKey: string | undefined, ...items: DbDataSource[]): Record<string, IDbPool> | null;
    validateKey(pools: Record<string, IDbPool>, username: string, uuidKey: unknown): [string, Record<string, IDbPool> | null];
    checkTimeout(pools: Record<string, IDbPool>, value: number, limit?: number): Promise<number>;
    readonly prototype: IDbPool;
    new(pool: unknown, poolKey: string, uuidKey?: AuthValue | null): IDbPool;
}

References

LICENSE

MIT

Keywords

FAQs

Package last updated on 24 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc