mirror of https://github.com/Budibase/budibase.git
5 changed files with 112 additions and 2 deletions
@ -0,0 +1,43 @@ |
|||
// const PouchDB = require("pouchdb")
|
|||
|
|||
// const COUCHDB_OPTIONS = {
|
|||
// url: {
|
|||
// type: "string",
|
|||
// required: true,
|
|||
// default: "localhost",
|
|||
// },
|
|||
// database: {
|
|||
// type: "string",
|
|||
// required: true,
|
|||
// },
|
|||
// // query: {
|
|||
// // type: "query",
|
|||
// // required: true,
|
|||
// // },
|
|||
// }
|
|||
|
|||
// class ElasticSearchIntegration {
|
|||
// constructor(config) {
|
|||
// this.config = config
|
|||
// this.client = new Client({ node: config.url })
|
|||
// }
|
|||
|
|||
// async query() {
|
|||
// try {
|
|||
// const result = await this.client.search({
|
|||
// index: this.config.index,
|
|||
// body: JSON.parse(this.config.query),
|
|||
// })
|
|||
// return result
|
|||
// } finally {
|
|||
// await this.client.close()
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
|
|||
// module.exports = {
|
|||
// schema: ELASTICSEARCH_OPTIONS,
|
|||
// integration: ElasticSearchIntegration,
|
|||
// }
|
|||
|
|||
|
|||
@ -0,0 +1,41 @@ |
|||
const { Client } = require("@elastic/elasticsearch") |
|||
|
|||
const ELASTICSEARCH_OPTIONS = { |
|||
url: { |
|||
type: "string", |
|||
required: true, |
|||
default: "localhost", |
|||
}, |
|||
index: { |
|||
type: "string", |
|||
required: true, |
|||
}, |
|||
query: { |
|||
type: "query", |
|||
required: true, |
|||
}, |
|||
} |
|||
|
|||
class ElasticSearchIntegration { |
|||
constructor(config) { |
|||
this.config = config |
|||
this.client = new Client({ node: config.url }) |
|||
} |
|||
|
|||
async query() { |
|||
try { |
|||
const result = await this.client.search({ |
|||
index: this.config.index, |
|||
body: JSON.parse(this.config.query), |
|||
}) |
|||
return result.body.hits.hits.map(({ _source }) => _source) |
|||
} finally { |
|||
await this.client.close() |
|||
} |
|||
} |
|||
} |
|||
|
|||
module.exports = { |
|||
schema: ELASTICSEARCH_OPTIONS, |
|||
integration: ElasticSearchIntegration, |
|||
} |
|||
Loading…
Reference in new issue