@otokton/common
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -8,5 +8,6 @@ import { Db } from 'mongodb'; | ||
get db(): Db; | ||
connect(): void; | ||
connect(schema?: JsonSchemaMongo[]): void; | ||
connectUser(): void; | ||
createCollection(schema: JsonSchemaMongo[]): void; | ||
fillCollection(): void; | ||
} |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mongodb_1 = require("mongodb"); | ||
var user_1 = __importDefault(require("../schema/jsonschema/user")); | ||
var AbstractMongoDatabase = /** @class */ (function () { | ||
@@ -16,3 +20,3 @@ function AbstractMongoDatabase(uri) { | ||
}); | ||
AbstractMongoDatabase.prototype.connect = function () { | ||
AbstractMongoDatabase.prototype.connect = function (schema) { | ||
var _this = this; | ||
@@ -24,5 +28,18 @@ this._client | ||
_this._db = connection.db(); | ||
if (schema) | ||
_this.createCollection(schema); | ||
}) | ||
.catch(function (err) { return console.error(err); }); | ||
}; | ||
AbstractMongoDatabase.prototype.connectUser = function () { | ||
var _this = this; | ||
this._client | ||
.connect() | ||
.then(function (connection) { | ||
console.log('Database connection established'); | ||
_this._db = connection.db(); | ||
_this.createCollection([user_1.default]); | ||
}) | ||
.catch(function (err) { return console.error(err); }); | ||
}; | ||
AbstractMongoDatabase.prototype.createCollection = function (schema) { | ||
@@ -29,0 +46,0 @@ var _this = this; |
{ | ||
"name": "@otokton/common", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28036
47
688