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.
potato-launcher/extensions/pouchdb/stores/apps.js

73 lines
1.4 KiB

import PouchdbHandler from './pouchdbHandler.js'
/**
* apps
*
* @author Björn Hase
* @license hhttps://www.gnu.org/licenses/gpl-3.0.en.html GPL-3
* @link https://gitea.node001.net/HerrHase/tellme-bot.git
*
*/
class AppsDatabase extends PouchdbHandler {
/**
*
* @param {object} data
* @return {object}
*
*/
create(data) {
data['type'] = 'apps'
return this.db.post(data)
.then((response) => {
console.log(response)
return response
})
}
/**
* find one app by id
*
* @param {string} id
* @return {mixed}
*
*/
findOneById(id) {
const query = {
'selector': {
'type': 'apps',
'_id' : id
}
}
return this.db.find(query).then((documents) => {
if (documents.docs.length === 0) {
return null
} else {
return documents.docs[0]
}
})
}
/**
* find apps
*
* @return {mixed}
*
*/
find() {
const query = {
'selector': {
'type': 'apps'
}
}
return this.db.find(query).then((documents) => {
return documents.docs
})
}
}
export default AppsDatabase