forked from tsai/budibase
4 changed files with 48 additions and 44 deletions
@ -1,43 +1,41 @@ |
|||||
// const PouchDB = require("pouchdb")
|
const PouchDB = require("pouchdb") |
||||
|
|
||||
// const COUCHDB_OPTIONS = {
|
const COUCHDB_OPTIONS = { |
||||
// url: {
|
url: { |
||||
// type: "string",
|
type: "string", |
||||
// required: true,
|
required: true, |
||||
// default: "localhost",
|
default: "localhost", |
||||
// },
|
}, |
||||
// database: {
|
database: { |
||||
// type: "string",
|
type: "string", |
||||
// required: true,
|
required: true, |
||||
// },
|
}, |
||||
// // query: {
|
view: { |
||||
// // type: "query",
|
type: "string", |
||||
// // required: true,
|
required: true, |
||||
// // },
|
}, |
||||
// }
|
} |
||||
|
|
||||
// class ElasticSearchIntegration {
|
class CouchDBIntegration { |
||||
// constructor(config) {
|
constructor(config) { |
||||
// this.config = config
|
this.config = config |
||||
// this.client = new Client({ node: config.url })
|
this.client = new PouchDB(`${config.url}/${config.database}`) |
||||
// }
|
} |
||||
|
|
||||
// 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,
|
|
||||
// }
|
|
||||
|
|
||||
|
async query() { |
||||
|
try { |
||||
|
const result = await this.client.allDocs({ |
||||
|
include_docs: true, |
||||
|
}) |
||||
|
return result.rows.map(row => row.doc) |
||||
|
} catch (err) { |
||||
|
console.error("Error querying couchDB", err) |
||||
|
throw err |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = { |
||||
|
schema: COUCHDB_OPTIONS, |
||||
|
integration: CouchDBIntegration, |
||||
|
} |
||||
|
|||||
Loading…
Reference in new issue