Guest User

Untitled

a guest
Mar 24th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. module.exports = (app, db, sequelize) => {
  2. const select = {
  3. type: sequelize.QueryTypes.SELECT
  4. };
  5. async function getPackagesInfo() {
  6. return new Promise((done) => {
  7. app.get('/apijs/packages/:page', (req, res) => {
  8. const resp = db
  9. .query(
  10. `SELECT ae_pack.id, ae_pack.package_description, ae_pack.full_description, ae_pack.buyin, ae_pack.created_by, ae_pack.bid_amount, ae_pack.package_type, ae_pack.percentage_offered, ae_pack.auction_end_date, ae_pack.is_streaming, a_urs.id AS userID, a_urs.name, a_urs.username, a_urs.email, ae_prof.large_image
  11. FROM aen_marketplace_packages ae_pack
  12. LEFT JOIN aen_users a_urs ON ae_pack.created_by = a_urs.id
  13. LEFT JOIN aen_marketplace_profile ae_prof ON ae_pack.created_by = ae_prof.user_id
  14. WHERE ae_pack.approved = 1
  15. ORDER BY ae_pack.ts
  16. DESC LIMIT 10
  17. OFFSET ${req.params.page * 10}`,
  18. select,
  19. )
  20. return done({
  21. Resp: resp,
  22. Res: res
  23. })
  24. });
  25. });
  26. };
  27. async function foo() {
  28. let a = await getPackagesInfo();
  29.  
  30. console.log(a.Resp);
  31.  
  32. a.Res.send(a.Resp)
  33. }
  34. foo();
  35. };
Add Comment
Please, Sign In to add comment