decks.js 615 B

1234567891011121314151617181920212223242526
  1. const decksDal = require("../dal/decksDal.js");
  2. class DecksRepository {
  3. //TODO continue
  4. // where UserID equals to logged in user's ID
  5. getDecksByUser(userID) {
  6. return decksDal.getDecksByUser(userID);
  7. }
  8. insertDeckByUser(userID, cards){
  9. return decksDal.insertDeckByUser(userID, cards);
  10. }
  11. deleteDeckByUser(userID, deckID) {
  12. return decksDal.deleteDeckByUser(userID, deckID)
  13. }
  14. }
  15. let decksRepository = null;
  16. function getSingleton() {
  17. return decksRepository = (decksRepository === null ? new DecksRepository(): decksRepository);
  18. }
  19. module.exports = getSingleton();