From 7a6e677b8927587ec771f3c9bfb18a1b51cd1f99 Mon Sep 17 00:00:00 2001
From: sovlookup <805408477@qq.com>
Date: Thu, 28 Jan 2021 21:42:40 +0800
Subject: [PATCH 1/8] add arangodb integration
---
.../DatasourceNavigator/icons/ArangoDB.svelte | 22 +++++
.../DatasourceNavigator/icons/index.js | 2 +
packages/server/package.json | 1 +
packages/server/src/integrations/arangodb.js | 87 +++++++++++++++++++
packages/server/src/integrations/index.js | 3 +
5 files changed, 115 insertions(+)
create mode 100644 packages/builder/src/components/backend/DatasourceNavigator/icons/ArangoDB.svelte
create mode 100644 packages/server/src/integrations/arangodb.js
diff --git a/packages/builder/src/components/backend/DatasourceNavigator/icons/ArangoDB.svelte b/packages/builder/src/components/backend/DatasourceNavigator/icons/ArangoDB.svelte
new file mode 100644
index 0000000000..0be4ca2663
--- /dev/null
+++ b/packages/builder/src/components/backend/DatasourceNavigator/icons/ArangoDB.svelte
@@ -0,0 +1,22 @@
+
+
+
+
\ No newline at end of file
diff --git a/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js b/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js
index 4f8d79dbf4..ff38782288 100644
--- a/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js
+++ b/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js
@@ -7,6 +7,7 @@ import S3 from "./S3.svelte"
import Airtable from "./Airtable.svelte"
import SqlServer from "./SQLServer.svelte"
import MySQL from "./MySQL.svelte"
+import ArangoDB from "./ArangoDB.svelte"
export default {
POSTGRES: Postgres,
@@ -18,4 +19,5 @@ export default {
S3: S3,
AIRTABLE: Airtable,
MYSQL: MySQL,
+ ARANGODB: ArangoDB,
}
diff --git a/packages/server/package.json b/packages/server/package.json
index fd8d5196a0..2ee2c79e22 100644
--- a/packages/server/package.json
+++ b/packages/server/package.json
@@ -56,6 +56,7 @@
"@sendgrid/mail": "^7.1.1",
"@sentry/node": "^5.19.2",
"airtable": "^0.10.1",
+ "arangojs": "^7.2.0",
"aws-sdk": "^2.767.0",
"bcryptjs": "^2.4.3",
"chmodr": "^1.2.0",
diff --git a/packages/server/src/integrations/arangodb.js b/packages/server/src/integrations/arangodb.js
new file mode 100644
index 0000000000..eefd656cbc
--- /dev/null
+++ b/packages/server/src/integrations/arangodb.js
@@ -0,0 +1,87 @@
+const arangojs = require("arangojs")
+const { FIELD_TYPES, QUERY_TYPES } = require("./Integration")
+// const arangodb = arangojs.Database
+const aql = arangojs.aql
+
+const SCHEMA = {
+ docs: "https://github.com/arangodb/arangojs",
+ datasource: {
+ url: {
+ type: FIELD_TYPES.STRING,
+ default: "http://localhost:8529",
+ required: true,
+ },
+ username: {
+ type: FIELD_TYPES.STRING,
+ default: "root",
+ required: true,
+ },
+ password: {
+ type: FIELD_TYPES.PASSWORD,
+ required: true,
+ },
+ databaseName: {
+ type: FIELD_TYPES.STRING,
+ default: "_system",
+ required: true,
+ },
+ collection: {
+ type: FIELD_TYPES.STRING,
+ required: true,
+ },
+ },
+ query: {
+ read: {
+ type: QUERY_TYPES.SQL,
+ },
+ create: {
+ type: QUERY_TYPES.JSON,
+ },
+ },
+}
+
+class ArangoDBIntegration {
+ constructor(config) {
+ config.auth = {
+ username: config.username,
+ password: config.password,
+ }
+
+ this.config = config
+ this.client = arangojs.arangojs(config)
+ }
+
+ async read(query) {
+ try {
+ const result = await this.client.query(query.sql)
+ let rl = []
+ await result.forEach((r)=> rl.push(r))
+ return rl
+ } catch (err) {
+ console.error("Error querying arangodb",err.message)
+ throw err
+ } finally {
+ this.client.close()
+ }
+ }
+
+ async create(query) {
+ const clc = this.client.collection(this.config.collection)
+ try {
+ const result = await this.client.query(aql`INSERT ${query.json} INTO ${clc} LET n = NEW RETURN NEW`)
+ let rl = []
+ await result.forEach((r)=> rl.push(r))
+ return rl
+ } catch (err) {
+ console.error("Error querying arangodb",err.message)
+ throw err
+ } finally {
+ this.client.close()
+ }
+ }
+}
+
+module.exports = {
+ schema: SCHEMA,
+ integration: ArangoDBIntegration,
+}
\ No newline at end of file
diff --git a/packages/server/src/integrations/index.js b/packages/server/src/integrations/index.js
index acb81992a9..8ff89f4900 100644
--- a/packages/server/src/integrations/index.js
+++ b/packages/server/src/integrations/index.js
@@ -7,6 +7,7 @@ const sqlServer = require("./microsoftSqlServer")
const s3 = require("./s3")
const airtable = require("./airtable")
const mysql = require("./mysql")
+const arangodb = require("./arangodb")
const DEFINITIONS = {
POSTGRES: postgres.schema,
@@ -18,6 +19,7 @@ const DEFINITIONS = {
S3: s3.schema,
AIRTABLE: airtable.schema,
MYSQL: mysql.schema,
+ ARANGODB: arangodb.schema,
}
const INTEGRATIONS = {
@@ -30,6 +32,7 @@ const INTEGRATIONS = {
SQL_SERVER: sqlServer.integration,
AIRTABLE: airtable.integration,
MYSQL: mysql.integration,
+ ARANGODB: arangodb.integration,
}
module.exports = {
From 1b6eb426c68e3d29a1057b13aeb1c6ac656b2d0f Mon Sep 17 00:00:00 2001
From: sovlookup <805408477@qq.com>
Date: Thu, 28 Jan 2021 21:48:29 +0800
Subject: [PATCH 2/8] add arangodb integration
---
packages/server/src/integrations/arangodb.js | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/packages/server/src/integrations/arangodb.js b/packages/server/src/integrations/arangodb.js
index eefd656cbc..f2aa54667e 100644
--- a/packages/server/src/integrations/arangodb.js
+++ b/packages/server/src/integrations/arangodb.js
@@ -1,7 +1,5 @@
-const arangojs = require("arangojs")
+const { Database, aql } = require("arangojs")
const { FIELD_TYPES, QUERY_TYPES } = require("./Integration")
-// const arangodb = arangojs.Database
-const aql = arangojs.aql
const SCHEMA = {
docs: "https://github.com/arangodb/arangojs",
@@ -48,7 +46,7 @@ class ArangoDBIntegration {
}
this.config = config
- this.client = arangojs.arangojs(config)
+ this.client = new Database(config)
}
async read(query) {
From 8996200d8deba244a67932c3607fd71dda16afa2 Mon Sep 17 00:00:00 2001
From: sovlookup <805408477@qq.com>
Date: Thu, 28 Jan 2021 22:17:39 +0800
Subject: [PATCH 3/8] add arangodb integration
---
packages/server/src/integrations/arangodb.js | 136 ++++++++++---------
1 file changed, 69 insertions(+), 67 deletions(-)
diff --git a/packages/server/src/integrations/arangodb.js b/packages/server/src/integrations/arangodb.js
index f2aa54667e..2b3ee1b11b 100644
--- a/packages/server/src/integrations/arangodb.js
+++ b/packages/server/src/integrations/arangodb.js
@@ -2,84 +2,86 @@ const { Database, aql } = require("arangojs")
const { FIELD_TYPES, QUERY_TYPES } = require("./Integration")
const SCHEMA = {
- docs: "https://github.com/arangodb/arangojs",
- datasource: {
- url: {
- type: FIELD_TYPES.STRING,
- default: "http://localhost:8529",
- required: true,
- },
- username: {
- type: FIELD_TYPES.STRING,
- default: "root",
- required: true,
- },
- password: {
- type: FIELD_TYPES.PASSWORD,
- required: true,
- },
- databaseName: {
- type: FIELD_TYPES.STRING,
- default: "_system",
- required: true,
- },
- collection: {
- type: FIELD_TYPES.STRING,
- required: true,
- },
+ docs: "https://github.com/arangodb/arangojs",
+ datasource: {
+ url: {
+ type: FIELD_TYPES.STRING,
+ default: "http://localhost:8529",
+ required: true,
},
- query: {
- read: {
- type: QUERY_TYPES.SQL,
- },
- create: {
- type: QUERY_TYPES.JSON,
- },
+ username: {
+ type: FIELD_TYPES.STRING,
+ default: "root",
+ required: true,
},
+ password: {
+ type: FIELD_TYPES.PASSWORD,
+ required: true,
+ },
+ databaseName: {
+ type: FIELD_TYPES.STRING,
+ default: "_system",
+ required: true,
+ },
+ collection: {
+ type: FIELD_TYPES.STRING,
+ required: true,
+ },
+ },
+ query: {
+ read: {
+ type: QUERY_TYPES.SQL,
+ },
+ create: {
+ type: QUERY_TYPES.JSON,
+ },
+ },
}
class ArangoDBIntegration {
- constructor(config) {
- config.auth = {
- username: config.username,
- password: config.password,
- }
-
- this.config = config
- this.client = new Database(config)
+ constructor(config) {
+ config.auth = {
+ username: config.username,
+ password: config.password,
}
- async read(query) {
- try {
- const result = await this.client.query(query.sql)
- let rl = []
- await result.forEach((r)=> rl.push(r))
- return rl
- } catch (err) {
- console.error("Error querying arangodb",err.message)
- throw err
- } finally {
- this.client.close()
- }
- }
+ this.config = config
+ this.client = new Database(config)
+ }
- async create(query) {
- const clc = this.client.collection(this.config.collection)
- try {
- const result = await this.client.query(aql`INSERT ${query.json} INTO ${clc} LET n = NEW RETURN NEW`)
- let rl = []
- await result.forEach((r)=> rl.push(r))
- return rl
- } catch (err) {
- console.error("Error querying arangodb",err.message)
- throw err
- } finally {
- this.client.close()
- }
+ async read(query) {
+ try {
+ const result = await this.client.query(query.sql)
+ let rl = []
+ await result.forEach(r => rl.push(r))
+ return rl
+ } catch (err) {
+ console.error("Error querying arangodb", err.message)
+ throw err
+ } finally {
+ this.client.close()
}
+ }
+
+ async create(query) {
+ const clc = this.client.collection(this.config.collection)
+ try {
+ const result = await this.client.query(
+ aql`INSERT ${query.json} INTO ${clc} LET n = NEW RETURN NEW`
+ )
+ let rl = []
+ await result.forEach(r => rl.push(r))
+ return rl
+ } catch (err) {
+ console.error("Error querying arangodb", err.message)
+ throw err
+ } finally {
+ this.client.close()
+ }
+ }
}
module.exports = {
schema: SCHEMA,
integration: ArangoDBIntegration,
-}
\ No newline at end of file
+}
From 0b8987f6a1411e61d1c95f8e52480d938bd745bf Mon Sep 17 00:00:00 2001
From: sovlookup <805408477@qq.com>
Date: Thu, 28 Jan 2021 22:20:15 +0800
Subject: [PATCH 4/8] add arangodb integration
---
packages/server/src/integrations/arangodb.js | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/packages/server/src/integrations/arangodb.js b/packages/server/src/integrations/arangodb.js
index 2b3ee1b11b..c886b6b918 100644
--- a/packages/server/src/integrations/arangodb.js
+++ b/packages/server/src/integrations/arangodb.js
@@ -52,9 +52,7 @@ class ArangoDBIntegration {
async read(query) {
try {
const result = await this.client.query(query.sql)
- let rl = []
- await result.forEach(r => rl.push(r))
- return rl
+ return result.forEach(r => rl.push(r))
} catch (err) {
console.error("Error querying arangodb", err.message)
throw err
@@ -69,9 +67,7 @@ class ArangoDBIntegration {
const result = await this.client.query(
aql`INSERT ${query.json} INTO ${clc} LET n = NEW RETURN NEW`
)
- let rl = []
- await result.forEach(r => rl.push(r))
- return rl
+ return result.forEach(r => rl.push(r))
} catch (err) {
console.error("Error querying arangodb", err.message)
throw err
From 9684def1ae97c1b115be0581e650bf54e156a2e2 Mon Sep 17 00:00:00 2001
From: sovlookup <805408477@qq.com>
Date: Thu, 28 Jan 2021 22:23:17 +0800
Subject: [PATCH 5/8] fix a little space
---
packages/server/src/integrations/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/server/src/integrations/index.js b/packages/server/src/integrations/index.js
index 8ff89f4900..9f9d5a1530 100644
--- a/packages/server/src/integrations/index.js
+++ b/packages/server/src/integrations/index.js
@@ -32,7 +32,7 @@ const INTEGRATIONS = {
SQL_SERVER: sqlServer.integration,
AIRTABLE: airtable.integration,
MYSQL: mysql.integration,
- ARANGODB: arangodb.integration,
+ ARANGODB: arangodb.integration,
}
module.exports = {
From aeee8af0d8b653854d070b7a733c91680780edfc Mon Sep 17 00:00:00 2001
From: sovlookup <805408477@qq.com>
Date: Thu, 28 Jan 2021 22:26:53 +0800
Subject: [PATCH 6/8] this commit is ok
---
packages/server/src/integrations/arangodb.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/packages/server/src/integrations/arangodb.js b/packages/server/src/integrations/arangodb.js
index c886b6b918..f4feed8246 100644
--- a/packages/server/src/integrations/arangodb.js
+++ b/packages/server/src/integrations/arangodb.js
@@ -52,6 +52,7 @@ class ArangoDBIntegration {
async read(query) {
try {
const result = await this.client.query(query.sql)
+ let rl = []
return result.forEach(r => rl.push(r))
} catch (err) {
console.error("Error querying arangodb", err.message)
@@ -67,6 +68,7 @@ class ArangoDBIntegration {
const result = await this.client.query(
aql`INSERT ${query.json} INTO ${clc} LET n = NEW RETURN NEW`
)
+ let rl = []
return result.forEach(r => rl.push(r))
} catch (err) {
console.error("Error querying arangodb", err.message)
From 2168991591e10867330f1b00bbc6bef87cd92b70 Mon Sep 17 00:00:00 2001
From: sovlookup <805408477@qq.com>
Date: Thu, 28 Jan 2021 22:35:41 +0800
Subject: [PATCH 7/8] cannot return result directly fix it
---
packages/server/src/integrations/arangodb.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/packages/server/src/integrations/arangodb.js b/packages/server/src/integrations/arangodb.js
index f4feed8246..2b3ee1b11b 100644
--- a/packages/server/src/integrations/arangodb.js
+++ b/packages/server/src/integrations/arangodb.js
@@ -53,7 +53,8 @@ class ArangoDBIntegration {
try {
const result = await this.client.query(query.sql)
let rl = []
- return result.forEach(r => rl.push(r))
+ await result.forEach(r => rl.push(r))
+ return rl
} catch (err) {
console.error("Error querying arangodb", err.message)
throw err
@@ -69,7 +70,8 @@ class ArangoDBIntegration {
aql`INSERT ${query.json} INTO ${clc} LET n = NEW RETURN NEW`
)
let rl = []
- return result.forEach(r => rl.push(r))
+ await result.forEach(r => rl.push(r))
+ return rl
} catch (err) {
console.error("Error querying arangodb", err.message)
throw err
From 31925ce3c030712630883bb7eb1c8574f67297fe Mon Sep 17 00:00:00 2001
From: sovlookup <805408477@qq.com>
Date: Thu, 28 Jan 2021 23:08:53 +0800
Subject: [PATCH 8/8] prettify code
---
packages/server/src/integrations/arangodb.js | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/packages/server/src/integrations/arangodb.js b/packages/server/src/integrations/arangodb.js
index 2b3ee1b11b..10449fc967 100644
--- a/packages/server/src/integrations/arangodb.js
+++ b/packages/server/src/integrations/arangodb.js
@@ -52,9 +52,7 @@ class ArangoDBIntegration {
async read(query) {
try {
const result = await this.client.query(query.sql)
- let rl = []
- await result.forEach(r => rl.push(r))
- return rl
+ return result.all()
} catch (err) {
console.error("Error querying arangodb", err.message)
throw err
@@ -67,11 +65,9 @@ class ArangoDBIntegration {
const clc = this.client.collection(this.config.collection)
try {
const result = await this.client.query(
- aql`INSERT ${query.json} INTO ${clc} LET n = NEW RETURN NEW`
+ aql`INSERT ${query.json} INTO ${clc} RETURN NEW`
)
- let rl = []
- await result.forEach(r => rl.push(r))
- return rl
+ return result.all()
} catch (err) {
console.error("Error querying arangodb", err.message)
throw err