mongoe
Version:
MongoDB driver with relational functionalities
30 lines (29 loc) • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Database = void 0;
var mongodb_1 = require("mongodb");
var _1 = require(".");
var Database = /** @class */ (function () {
function Database(url, name, relations) {
this.relations = {};
this.name = name;
this.handle = mongodb_1.MongoClient.connect(url, {
useUnifiedTopology: true
}).then(function (client) { return client.db(name); });
this.registerRelations(relations !== null && relations !== void 0 ? relations : {});
}
Database.prototype.collection = function (name, config) {
return new _1.Collection(this, name, config);
};
Database.prototype.dropDatabase = function () {
return this.handle.then(function (db) { return db.dropDatabase(); });
};
Database.prototype.registerRelations = function (relations) {
_1.registerRelations(this.relations, relations);
};
Database.prototype.assertIntegrity = function () {
return _1.verifyIntegrity(this);
};
return Database;
}());
exports.Database = Database;