@btc-vision/bsi-common
Version:
Common library for OP_NET.
25 lines (24 loc) • 761 B
JavaScript
export class MongoCredentials {
constructor(creds) {
this.databaseName = '';
this.username = '';
this.password = '';
this.host = '';
this.port = '';
this.prefix = ``;
this.username = creds.username;
this.password = creds.password;
this.host = creds.host;
this.port = creds.port;
this.prefix = creds.prefix || '';
this.databaseName = creds.databaseName;
}
get connectionUri() {
if (this.prefix) {
return `mongodb${this.prefix}://${this.username}:${this.password}@${this.host}/${this.databaseName}`;
}
else {
return `mongodb://${this.username}:${this.password}@${this.host}:${this.port}`;
}
}
}