Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static async _getDatabase () {
if (Model._database) {
return Model._database
}
const dbName = this.options.database
const host = this.options.host || 'localhost'
const port = this.options.port || 8529
const username = this.options.username || 'root'
const password = this.options.password || ''
const url = this.options.url || `http://${username}:${password}@${host}:${port}`
const db = arangojs({
url
})
try {
await db.createDatabase(dbName)
} catch (e) {
// throw new Error(get(e, 'response.body.errorMessage', e))
}
db.useDatabase(dbName)
Model._database = db
return db
}