Created
January 25, 2017 00:36
-
-
Save afucher/3b5b8aabccb831f469ea6014d0e661f9 to your computer and use it in GitHub Desktop.
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
| GroupController.addStudent = (id, student_id) => { | |
| return Group.findById(id) | |
| .then((g) => new Promise((resolve, reject) => { | |
| if(g){ | |
| resolve(g); | |
| }else{ | |
| reject('??'); | |
| } | |
| })); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pode encadear as promises através do then():
Ou melhor ainda, faça
findByIdrejeitar a promise se não encontrar o objeto com a id: