nodejs-schema-rules
Version:
The CLI tool automatically generates basic validation rules for popular libraries such as JOI, ValidatorJS and @vinejs/vine based on your database table schema!
50 lines (49 loc) • 1.71 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PostgresDatabase = void 0;
const pg_1 = require("pg");
class PostgresDatabase {
constructor(config) {
this.client = new pg_1.Client(config);
}
connect() {
return __awaiter(this, void 0, void 0, function* () {
try {
yield this.client.connect();
}
catch (error) {
throw error;
}
});
}
query(sql) {
return __awaiter(this, void 0, void 0, function* () {
try {
return yield this.client.query(sql);
}
catch (error) {
throw error;
}
});
}
end() {
return __awaiter(this, void 0, void 0, function* () {
try {
yield this.client.end();
}
catch (error) {
throw error;
}
});
}
}
exports.PostgresDatabase = PostgresDatabase;