Created
February 24, 2018 02:15
-
-
Save robertz/c3bd0876c45bf9fa631038fddfba6346 to your computer and use it in GitHub Desktop.
Export the controller methods to support the app routes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Payee = require("../models/Payee"); | |
| const Payments = require("../models/Payment"); | |
| exports.getPayees = async (req, res) => { | |
| return Payee.find({ owner: req.params.userid }) | |
| .sort({ day: 1 }) | |
| .then(payees => { | |
| res.json(payees); | |
| }); | |
| }; | |
| exports.getPayee = async (req, res) => { | |
| return Payee.findOne({ owner: req.params.userid, _id: req.params.payeeid }) | |
| .then(payee => { | |
| res.json(payee); | |
| }) | |
| }; | |
| exports.getPayments = async (req, res) => { | |
| return Payments.find({ owner: req.params.userid }) | |
| .sort({ ref: -1 }) | |
| .then(payments => { | |
| res.json(payments); | |
| }) | |
| } | |
| exports.getPayeePayments = async (req, res) => { | |
| return Payments.find({ owner: req.params.userid, payee: req.params.payeeid }) | |
| .sort({ ref: -1 }) | |
| .then(payments => { | |
| res.json(payments); | |
| }); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment