Get a request item by id and type

This commit is contained in:
2019-06-28 19:21:54 +02:00
parent ac027a97d6
commit 9f1badc1b1
3 changed files with 40 additions and 1 deletions

View File

@@ -20,7 +20,7 @@ class RequestRepository {
downloaded: '(select status from requests where id is request.id and type is request.type limit 1)',
// deluge: '(select status from deluge_torrent where id is request.id and type is request.type limit 1)',
// fetchAllFilterStatus: 'select * from request where '
read: 'select * from request where id is ? and type is ?'
read: 'select id, title, year, type, status, requested_by, ip, date, user_agent from requests where id is ? and type is ?'
};
}
@@ -96,6 +96,22 @@ class RequestRepository {
});
}
/**
* Get request item by id
* @param {String} id
* @param {String} type
* @returns {Promise}
*/
getRequestByIdAndType(id, type) {
console.log('id & type', id, type)
return Promise.resolve()
.then(() => this.database.get(this.queries.read, [id, type]))
.then(row => {
assert(row, 'Could not find request item with that id and type')
return JSON.stringify(row)
})
}
/**
* Fetch all requests with optional sort and filter params
* @param {String} what we are sorting by