xud
Version:
Exchange Union Daemon
41 lines (40 loc) • 1.44 kB
TypeScript
import { ModelCtor, Sequelize } from 'sequelize';
import { XuNetwork } from '../constants/enums';
import Logger from '../Logger';
import * as Models from './models';
import * as db from './types';
declare type Models = {
Currency: ModelCtor<db.CurrencyInstance>;
Node: ModelCtor<db.NodeInstance>;
SwapDeal: ModelCtor<db.SwapDealInstance>;
Pair: ModelCtor<db.PairInstance>;
ReputationEvent: ModelCtor<db.ReputationEventInstance>;
Order: ModelCtor<db.OrderInstance>;
Trade: ModelCtor<db.TradeInstance>;
Password: ModelCtor<db.PasswordInstance>;
};
/** A class representing a connection to a SQL database. */
declare class DB {
private logger;
private storage?;
sequelize: Sequelize;
models: Models;
private static VERSION;
/**
* @param storage the file path for the sqlite database file, if ':memory:' or not specified the db is stored in memory
*/
constructor(logger: Logger, storage?: string | undefined);
/**
* Initialize the connection to the database.
* @param initDb whether to intialize a new database with default values if no database exists
*/
init: (network?: XuNetwork, initDb?: boolean) => Promise<void>;
/**
* Checks whether the database is new, in other words whether we are not
* loading a preexisting database from disk.
*/
private isNewDb;
close: () => Promise<void>;
}
export default DB;
export { Models };