Created
June 14, 2019 11:18
-
-
Save desaijay315/3a8eb785be8b6b285d8d9b0fc8626449 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
router.get('/posts',authenticate, async (req,res) => { | |
//const _ispublished = req.query.published; | |
const match = {} | |
if(req.query.published){ | |
match.published = req.query.published === 'true' | |
} | |
try { | |
await req.user.populate({ | |
path:'posts', | |
match | |
}).execPopulate() | |
res.send(req.user.posts) | |
} catch (error) { | |
res.status(500).send() | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment