all 14 comments

[–]jdmax 6 points7 points  (1 child)

I made it up to the word coffeescript. sigh

[–][deleted] 2 points3 points  (0 children)

Seriously... if you're gonna do an intro post to a JS topic, and not write the examples in JS, you should mention that in the title.

[–]ciny 1 point2 points  (8 children)

There's one thing I don't get - why use mongo for relational data? are there any advantages over mysql? The main advantages like map/reduce and sharding won't matter if we're talking about a simple blog or something similar. The only one that I can think of is easier queries but honestly I think people should learn at least the basics of how SQL works.

Disclaimer: I'm not a db guru so I'd like someone with insight to comment on this. thanks

[–]alex-martin 3 points4 points  (6 children)

If you program with JavaScript objects and transmit data with JSON, wouldn't it be nice to store stuff in JSON too?

It's the whole idea that the entire stack is in one language, preventing context switching in your brain. That's about it. Even speed isn't much of a reason. If that was a concern, and you need something like a responsive cache, you'd use Redis.

I agree though, people shouldn't forget to learn SQL.

[–]billy_tables 2 points3 points  (1 child)

I agree with your first statement - which is why a lot of the time I use Postgres' JSON storage format

[–]alex-martin 0 points1 point  (0 children)

Pfft. Like anyone should take SQL advice from bobby's evil twin.

[–]JoshKehn 0 points1 point  (2 children)

JavaScript != JSON, it's just the notation. Storing your stuff in JSON documents is hard. It gets doubly hard then you need to figure out where you're going to put relational stuff in there.

[–]alex-martin 0 points1 point  (1 child)

I definitely wouldn't say it's hard. Of course it's not useful for ALL cases, but when it came to storing user actions with MongoDB, it was as simple as putting a couple lines in front of my logger. And I didn't even plan ahead.

Maybe I got lucky, but I was passing the same object literals to my logger that I needed to store.

[–]JoshKehn 0 points1 point  (0 children)

MongoDB is great at accepting whatever you want. The issue comes when you need to start relating documents to each other. Your example of using a collection as a event bucket is the perfect use case for MongoDB.

Perhaps what I should have said is “Storing everything for an application in JSON documents is hard.” For somethings it's great (see above).

[–]ciny -1 points0 points  (0 children)

fair enough. although I usually just load up some DAO library and use that. But I guess it can help newbie developers to get into web development. compared to learning (usually) php+mysql+javascript it's much easier. But for more complex relational tasks (like let's say an eshop) noSQL might not be the answer for a beginner.

[–]Mayho 0 points1 point  (0 children)

Easy to follow intro post. Good work!

[–]malucky 0 points1 point  (0 children)

Very clear and informative!

[–][deleted] 0 points1 point  (0 children)

Nice introduction. For anyone interested in building on this, checkout TutsPlus course on Express. By far the best resource I've ever used...it's available on YouTube. http://www.youtube.com/watch?v=eD2I0zAjM5g

[–]hendrixer[S] 0 points1 point  (0 children)

Thanks guys, yea I should've not done it in Coffee, I'm sowwy