@sphereon/ssi-sdk.agent-config
Version:
31 lines • 1.43 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.typeormDate = exports.typeOrmDateTime = exports.getDbType = void 0;
const dataSources_1 = require("./dataSources");
const getDbType = (opts) => {
var _a, _b, _c;
const type = (_c = (_b = (typeof process === 'object' ? (_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.DB_TYPE : undefined)) !== null && _b !== void 0 ? _b : dataSources_1.DataSources.singleInstance().defaultDbType) !== null && _c !== void 0 ? _c : opts === null || opts === void 0 ? void 0 : opts.defaultType;
if (!type) {
throw Error(`Could not determine DB type. Please set the DB_TYPE global variable or env var to one of 'postgres' or 'sqlite'`);
}
return type;
};
exports.getDbType = getDbType;
const typeOrmDateTime = (opts) => {
switch ((0, exports.getDbType)(opts)) {
case 'postgres':
return 'timestamp';
case 'sqlite':
case 'react-native':
return 'datetime';
default:
throw Error(`DB type ${(0, exports.getDbType)(opts)} not supported. Right now only sqlite, react-native and postgresql are supported`);
}
};
exports.typeOrmDateTime = typeOrmDateTime;
const typeormDate = (opts) => {
// The same for both DBs
return 'date';
};
exports.typeormDate = typeormDate;
//# sourceMappingURL=typeormTypes.js.map