Hacker News new | past | comments | ask | show | jobs | submit login
MongoDB interactive tutorial (mongly.com)
126 points by latch on March 16, 2011 | hide | past | favorite | 25 comments



Funny easter egg: If you do db.unicorns.remove({}) after it asks you to list the collections, typing "db.unicorns.count()" will redirect you here: http://www.thinkgeek.com/caffeine/wacky-edibles/e5a7/

(At least I think it's an easter egg, I didn't get all the way through. Maybe murdering unicorns is a normal part of the tutorial)


This tutorial was totally cool! Props to the guy who made this, and for doing something like this while in his bored spare time... 1 complaint however is that it doesn't explain much about the difference between MongoDB and MySQL, or other databases. I was really hoping to get to hear how it compares, what the pros and cons are out of using this vs. other databases


I found this insanely helpful! At first I thought the tutorial was just a scripted app which only listened for the right queries to move on. I was a little blown away when I realized I could run other queries against the tutorial db.


once you get to lesson 10 or about, it limits the input quite a bit since the lessons start to build atop each other. Before that, or after you are done, you can do a lot.

The commands are executed against a real unicorns mongodb collection (each user having his or her own)...so you are only limited by what's been implemented in the javascript shell and on the thin proxy backend.

This does mean that someone who wanted to take the server down probably wouldn't have to try very hard.


Awesome tutorial. It's always fun to mess around with things like this. I am running into a problem with sorting though. On lesson 6 I am sorting with {weight:1} which the tutorial says is wrong, but I get the same answer as sorting on {weight: -1} which is correct according to the tutorial. Or is this a mongodb thing? Anyway, keep up the good work.


weight:-1 is correct..since you want the heaviest, you sort by weight descending. weight:1 should have returned documents in ascending order but wasn't working. It's fixed now on the tutorial..as well as in the core web console: https://github.com/karlseguin/Mongo-Web-Admin/commit/761cd4e...


A few latency issues... or is it just tutorial related sluggishness or is it representative of Mongos' CAP tradeoffs? I guess 'eventually consistent' kicked in by the second find query. If that is what really happened, it is really cool to visualize 'eventually consistent'!

Output from back to back db.users.find() command. It took a while for Johnny to be updated to Cash.

> db.users.find();

[ { "_id" : { "$oid" : "4d82805ecc9374271b03dd8a" }, "name" : "Johnny", "languages" : [ "ruby", "c" ] }, { "_id" : { "$oid" : "4d828066cc9374271b03dd8b" }, "name" : "Sue", "languages" : [ "scala", "lisp" ] } ]

> db.users.find();

[ { "_id" : { "$oid" : "4d82805ecc9374271b03dd8a" }, "name" : "Cash", "languages" : [ "english" ] }, { "_id" : { "$oid" : "4d828066cc9374271b03dd8b" }, "name" : "Sue", "languages" : [ "scala", "lisp" ] } ] >

Ed: Oops. I was on the try.mongodb.org page. Not the linked article. I am trying that now.


Lesson 6 asks for 'Here's a tricky one: get ONLY the NAMES of the 2nd and 3rd heaviest male unicorns' Which made me query: db.unicorns.find({gender:'m'}, {name:1, _id:0}).sort({weight:-1}).skip(1).limit(2) but it wants: db.unicorns.find({gender:'m'}, {name:1}).sort({weight:-1}).skip(1).limit(2)


Hey, thanks! I didn't know you could exclude the _id like that...I can actually make us of that trick. Going to push out a new version with that, and a few other fixes, in a few.


Lesson 7 quit on me. How do I skip lessons? Ze mouze clickz, zey do nottingz.


lesson(8);


Dead simple, and really clever. I actually think this has a really handy pace and tone.


Good tutorial.

After lesson 16 all the instructions disappeared and I was left with a white screen. Tried to go to a different lesson or the restart command but the instructions didn't come back. Couldn't replicate the problem unfortunately.


ya, I've seen this but I can't reproduce it either. Really have no idea. Refresh and lesson(17); should at least let you continue from where you left off.


I love interactive tutorials! I wish there would be one for python I could pass around (is there?).

The timeouts on this particular page could use some tweaking, though.


I tried the first one "It's easy, just enter db.getCollectionNames();"

Received: "undefined method `collection_names' for nil:NilClass"

Edit: It's relying on my cookie which wasn't enabled, oops.

The official MongoDB interactive tutorial: http://try.mongodb.org/

Seems to be a clone of redis: http://try.redis-db.com/


Actually, the Redis one was a clone of MongoDB's.


Beautifully designed. It feels as if I am talking to a real person.


In the real world you probably wouldn't want to have a dob field on the unicorns table. Instead just use the timestamp embedded into the _id field.

Pretty good overall though.


"In the real world you probably wouldn't want to have a dob field on the unicorns table. Instead just use the timestamp embedded into the _id field."

The real world unicorns are not born on the same second that their db record is created.


The issue with that is if your DB gets backed and starts queuing writes, the timestamps will be skewed. Obviously this isn't always a show stopper, but a caveat nonetheless.


Actually the _id is usually created client-side so the timestamp will reflect when the application created the object rather than when it was processed by the DB. The only major exception is when the DB creates the _id for an upsert.


I still prefer the tutorial on the homepage of mongodb.org. Click "Try it out" and type "tutorial". This is very well done too, though.


The DOM has exactly eight words of content and no forms or links at all. I'm worried about this trend of tutorials from authors who fail to get the very basics like progressive enhancement right. We should be showing pages with better authoring than average to novices, because most of the web will eventually converge on the quality of the average tutorial today.


I'd love something like this for either Javascript itself or Node.js - Any ideas anyone?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: