Learning MongoDB // The CRUD

If you have not been following my blog for the training i am undertaking on mongodb, it is time you do so now because this is getting way too much interesting. Last night I took the Week 2 course and it was a slam dunk. I opened tbe course at around midnight and I wanted to finish the same yesterday as I wanted to submit my homework and get on the scorecard. It took me around 3 hours and honestly I skipped the last 5 Lectures. I realized that a) I should not be doing this past midnight as it gets real hard to focus with you wanting to sleep and b) should not have a movie running on the side. Anyways, I managed to finish the course in just under 3 hours and it felt good.


What I learnt?

Week 2 is about CRUD which in mongo terms is Insert, Find, Update, Remove (they didn’t have a cool acronym like CRUD). First half of the course was heavy in mongoshell and work with various commands, The session was high enough to share all possible commands especially when you have query with various operators like $gt, $lt, $and, $or and several others. The 2nd half of the course moved over into Java and we were asked to do similar operations using the Java driver for Mongo // there were no frameworks like Spring and it was all native Mongo. To list down all that I learnt:

a) insert()

b) findOne() and find()

c) update() (including multi updates)

d) remove()

e) Query using $gt, $lt, regex, $exists, $type, $or, $and, arrays, $in, $all, $set, $unset, $push, $pop, $pushAll, $pullAll

f) Cursors and find, sort, limit (paginate)

When I tell you that this week will come as a big surprise and it is heavy considered to what Week 1 is // so be prepared to focus.


My Takeaways

This week we did not get into modelling where I really want to go to, but this week was insightful as it allowed me to understand the power of the mongo’s schemaless design principle. There are ways in mongo that we can get data and only get what we need, we can even set what we need to. So the need to work on various joins and managing schemas as the domains grows is really pretty easy in mongo. We have been looking to use mongo in a setting to manage data for various tenants and the profile itself will vary not just from a tenant to tenant, but also between tenants as they might work with multiple profiles and also at times just may need to update profiles. Last night, provided me a good understanding of how we can meet all those uses and not dealing with a lot of Java boilerplate code aka delegating the stuff/tasks over to mongo and let it do it for us.

The other big takeaway was that working with mongo’s document structure is much more simpler to what RDBMS is. While was I working in mongoshell where I was using JavaScirpt to write code and later when i moved over to Java classes it was fairly simple. It was all about knowing 3 classes (if not 2) and you are done. Working with Maps (or Dictionaries) is pretty simple and using that knowledge in any language cant really be difficult. I was able to go back and learn JavaSciprt all over again and code a logic pretty quick.


Key Takeaways

a) The flexibility that MongoDB brings with itself is pure awesomeness and amazing // it has the capability to get anyone started in matter of minutes

b) The operations and way they work on the underlying documents is pretty slick and present several opportunities – must try

Initiate your idea here...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s