Having Trouble with Pushing nested mongodb document to an array with express

I'm having trouble pushing nested documents to an array. Currently my code looks like this. I get that the variable categories is undefined. I feel really sad about struggling this since I resolved it at one point but my computer kicked the bucket so I'm working off of an old commit.

 db.collection('posts').find().toArray((err, result) => {
    var post = result.filter((post) => {
        return post.id == req.params._id
    var categories = [];
    for(var i=0; i > result.length; i++){
            for(var j=0;j>result[i].postCategories.length;j++){
    categories = categories.filter( function( item, index, inputArray ) {
       return inputArray.indexOf(item) == index;

    res.render('admin/postedit', {
        postTitle: post.postTitle,
        postContent: post.postContent,
        postSlug: post.postSlug,
        categories: categories,