DbSearcher.js 520 B

12345678910111213141516171819202122232425262728
  1. class DbSearcher {
  2. constructor(db) {
  3. this.db = db;
  4. }
  5. async search(query) {
  6. const db = this.db;
  7. let result = [];
  8. if (query.author) {
  9. //
  10. } else {
  11. result = await db.select({
  12. table: 'author',
  13. map: `(r) => ({id: r.id, author: r.author})`
  14. });
  15. }
  16. if (query.limit) {
  17. result = result.slice(0, query.limit);
  18. }
  19. return result;
  20. }
  21. }
  22. module.exports = DbSearcher;