@cocalc/database
Version:
CoCalc: code for working with our PostgreSQL database
40 lines (39 loc) • 1.76 kB
JavaScript
;
/*
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
* License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.db = exports.PUBLIC_PROJECT_COLUMNS = exports.PROJECT_COLUMNS = exports.count_result = exports.all_results = exports.one_result = exports.expire_time = exports.pg_type = void 0;
/*
PostgreSQL database entry point.
Do not import any of the submodules directly unless you
know exactly what you're doing.
COPYRIGHT : (c) 2021 SageMath, Inc.
*/
const record_connect_error_1 = require("./postgres/record-connect-error");
const base = require("./postgres-base");
exports.pg_type = base.pg_type, exports.expire_time = base.expire_time, exports.one_result = base.one_result, exports.all_results = base.all_results, exports.count_result = base.count_result, exports.PROJECT_COLUMNS = base.PROJECT_COLUMNS, exports.PUBLIC_PROJECT_COLUMNS = base.PUBLIC_PROJECT_COLUMNS;
// Add further functionality to PostgreSQL class -- must be at the bottom of this file.
// Each of the following calls composes the PostgreSQL class with further important functionality.
// Order matters.
let theDB = undefined;
function db(opts = {}) {
if (theDB === undefined) {
let PostgreSQL = base.PostgreSQL;
for (const module of [
"server-queries",
"blobs",
"synctable",
"user-queries",
"ops",
]) {
PostgreSQL = require(`./postgres-${module}`).extend_PostgreSQL(PostgreSQL);
}
theDB = new PostgreSQL(opts);
(0, record_connect_error_1.setupRecordConnectErrors)(theDB);
}
return theDB;
}
exports.db = db;
//# sourceMappingURL=index.js.map