router.get('/renew/:id',ensureAuthenticated , function(req, res){
  // console.log();
  Store.findById(req.params.id, function(err, stores){
    // console.log(stores);
    Plan.find({}, function(err, plans){
      Transaction.findOne({"app":req.body.appID},{"sort":{"startDate":-1}},function(err, transOne){
        console.log("transOne :" +transOne);
        Transaction.find({"_id":transOne._id},function(err, transactions){
          console.log("trans :"+transactions);
          res.render('edit_store', {
            title:'Edit Store',
            stores:stores,
            user:login.userLogin,
            plans:plans,
            transactions:transactions
          });
        });
      });
    });
  });
});
Why is my transOne Variable undefined?
TransOne Undefined.
So, my transaction variable is errors.
I want to select the most recent document that has appID I choose.
And I want to know how to get the result of findOne.
I used:
transOne = Transaction.findOne({"app":req.body.appID},{"sort":{"startDate":-1}});
But, it return "[Object Object]".
 
     
    