arango-tools
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "arango-tools", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "tools for working with ArangoDB", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,8 +8,8 @@ # ArangoTools | ||
Influenced by the great [DX](https://bit.ly/2YomoYC) of MongoDB, and the | ||
declarative model, wherever permissions allow, arango-tools will create | ||
declarative model, wherever permissions allow arango-tools will create | ||
resources you've said should exist. Both the `ensure` and `migrate` functions | ||
are idempotent, and create resources only when the don't exist. | ||
are idempotent, and create resources only when they don't exist. | ||
Basically you should be able to state your intent, and know when it couldn't | ||
happen. Think [dotenv-save](https://www.npmjs.com/package/dotenv-safe), but for | ||
Basically, you should be able to state your intent and know when it couldn't | ||
happen. Think [dotenv-safe](https://www.npmjs.com/package/dotenv-safe), but for | ||
database stuff. | ||
@@ -16,0 +16,0 @@ |
@@ -6,3 +6,5 @@ const { Database, aql } = require('arangojs') | ||
try { | ||
await connection.createDatabase(migration.databaseName, migration.users) | ||
await connection.createDatabase(migration.databaseName, { | ||
users: migration.users, | ||
}) | ||
} catch (e) { | ||
@@ -19,4 +21,6 @@ // if the error is just a duplicate name thats ok. We'll just wrap it | ||
const [user] = migration.users | ||
const output = new Database({ url: migration.url }) | ||
output.useDatabase(migration.databaseName) | ||
const output = new Database({ | ||
url: migration.url, | ||
databaseName: migration.databaseName, | ||
}) | ||
await output.login(user.username, user.passwd) | ||
@@ -23,0 +27,0 @@ |
@@ -18,6 +18,5 @@ const assign = require('assign-deep') | ||
const newConnection = (rootPass, url) => { | ||
const sys = new Database({ url }) | ||
sys.useDatabase('_system') | ||
sys.useBasicAuth('root', rootPass) | ||
const newConnection = async (rootPass, url) => { | ||
const sys = new Database({ url, databaseName: '_system' }) | ||
await sys.login('root', rootPass) | ||
return sys | ||
@@ -30,3 +29,2 @@ } | ||
let state = {} | ||
let dbResults, documentCollectionResults | ||
for (const migration of migrations) { | ||
@@ -36,5 +34,5 @@ // Add the url to each migration. | ||
switch (migration.type) { | ||
case 'database': | ||
dbResults = await migrateDatabase( | ||
newConnection(rootPass, url), | ||
case 'database': { | ||
const dbResults = await migrateDatabase( | ||
await newConnection(rootPass, url), | ||
migration, | ||
@@ -44,5 +42,6 @@ ) | ||
break | ||
case 'documentcollection': | ||
documentCollectionResults = await migrateDocumentCollection( | ||
newConnection(rootPass, url), | ||
} | ||
case 'documentcollection': { | ||
const documentCollectionResults = await migrateDocumentCollection( | ||
await newConnection(rootPass, url), | ||
migration, | ||
@@ -54,5 +53,6 @@ ) | ||
break | ||
case 'edgecollection': | ||
var edgeCollectionResults = await migrateEdgeCollection( | ||
newConnection(rootPass, url), | ||
} | ||
case 'edgecollection': { | ||
const edgeCollectionResults = await migrateEdgeCollection( | ||
await newConnection(rootPass, url), | ||
migration, | ||
@@ -64,5 +64,7 @@ ) | ||
break | ||
case 'geoindex': | ||
await migrateGeoIndex(newConnection(rootPass, url), migration) | ||
} | ||
case 'geoindex': { | ||
await migrateGeoIndex(await newConnection(rootPass, url), migration) | ||
break | ||
} | ||
default: | ||
@@ -69,0 +71,0 @@ console.log('Not implemented yet: ', migration) |
20337
532