11. August 2018

Mongoose delete/pull ObjectID within an array

Slots

I wanted to delete an ID inside slots array, It took me a while to find the answer, hopefully this small snippet can help you.

// Delete item in users
User.findOneAndUpdate(
  { '_id': userID, 'username': username },
  { $pull: { slots: cardID }}, function(err, data) {
    if (err) res.render('error', { 
      message: 'Sorry failed to delete card id in users',
      error: { status: err, stacks: 'failed to delete card id in users' }
    });
  }
)

I’m using Express 4, Mongoose 5.2.7 and mongodb hosted in mlab.

24. June 2018

React-Static and Firebase

This is what’s keeping me busy since last week. I feel more comfortable with react-static than gatsby. I think I will be using this in my make others that doesn’t require a server side.

17. June 2018

Gatsby and Firebase

I spend days searching for the right Nodejs framework with reactjs as the view and good with seo. I’m already leaning towards meteor, but the problem is, I don’t want to maintain server, and it’s not seo friendly, you have to do a couple of configutaions to handle that. But the good thing about it is, it’s reactive, you get a real-time database, it has user modules, which is really cool, and you get to use reactjs. Right now, the user module is using blaze, but, you can always use blaze inside react. There’s tutorial you can find on their website about it. And another thing why I liked meteor, you can use your metoer API inside in react-native using react-native-meteor.

Gatsby and Firebase seems right for me

So I ended up using gatsby and firebase for my projects, as of this moment I’m trying out gatsby-source-firebase. A couple of things I liked about it, I don’t have to maintain server, It’s seo friendly, it’s a html static generator, it’s using graphql that pulls out data from the others server and create pages for you.

I’m won’t be comparing metoer and gatsby, meteor is different beast and a lot more powerful, It just turn’s out that gatsby is what I need at the moment for my projects. If you want to use gatsby, they have a good document on their website, and lots of samples and starter projects to start with.