You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import PouchDB from 'pouchdb'
|
|
|
|
import PouchDBfind from 'pouchdb-find'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PouchdbHandler, for create
|
|
|
|
*
|
|
|
|
* @author Björn Hase
|
|
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3
|
|
|
|
* @link https://gitea.node001.net/HerrHase/potato-launcher.git
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
class PouchdbHandler {
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
constructor() {
|
|
|
|
PouchDB.plugin(PouchDBfind)
|
|
|
|
|
|
|
|
this.db = new PouchDB('.storage/pouchdb/apps', {
|
|
|
|
revs_limit: 0
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* adding index for current class
|
|
|
|
*
|
|
|
|
* @param {array} fields
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
createIndex(fields) {
|
|
|
|
|
|
|
|
// adding index
|
|
|
|
try {
|
|
|
|
this.db.createIndex({
|
|
|
|
index: {
|
|
|
|
fields: fields
|
|
|
|
}
|
|
|
|
}).then(() => {
|
|
|
|
|
|
|
|
})
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PouchdbHandler
|