hisaac.net


Solo Project Day Seven: To The Database and Back Again

This is technically the eighth day since I began my solo project, but I didn't do any work on the project on Sunday (although I did do some other web work).

Today was a very productive day for me. I got more done than I expected to, and I made it to MVP (Minimum Viable Product)! I didn't think I'd get to MVP this fast, but I'm glad I did. At Prime, we all get industry mentors to work with, and tomorrow we meet with them to show them our solo projects. I was really hoping I'd have a usable product to show them.

Tasks Accomplished

// client side
$http.post('/db/draft/newBlank', self.authFactory)
  .then(function(res){
    // move info from newly created blank draft into draft factory
    self.draftFactory._id = res.data._id;
    self.draftFactory.text = res.data.text;
    self.draftFactory.dateCreated = res.data.dateCreated;
  });

// server side
router.post('/draft/newBlank', function(req, res){
  User.findOne({ uid: req.body.uid }, function(error, user){
    user.drafts.push(new Draft);
    if(error){
      res.sendStatus(500);
    } else {
      user.save();
      res.status(201).send(user.drafts[user.drafts.length-1]);
    }
  });
});
// client side
self.saveDraft = function(){
  $http.post('/db/draft/saveDraft/' + self.draftFactory.text, self.draftFactory);
};

// server side
router.post('/draft/saveDraft/:tweetText', function(req, res){
  var query = { 'drafts._id': req.body._id };
  var update = { 'drafts.$.text': req.params.tweetText };
  var options = { upsert: true, new: true, setDefaultsOnInsert: true };

  User.findOneAndUpdate(query, update, options, function(error, result){
    if(error){
      res.sendStatus(500);
    } else {
      res.sendStatus(201);
    }
  });
});

Tomorrow's task will be mainly styling. I want the app to look nice for my mentors.

Today's Research

#twitter #projects #crow #webdev