I don't see the benefit of using mongoose over mongodb. Am I missing something?

I don't see the benefit of using mongoose over mongodb. Am I missing something?
0

#1

Granted I haven’t done the FCC exercises but I’m tinkering with the documentation and other than some shorter syntax it doesnt seem like that big a deal.

I also want to understand mongodb commands a bit deeper before I mess with mongoose so maybe thats my excuse


#2

Mongo is schemaless - you can think of it kinda like a big, really basic object - myUsers: { id1: "json document with info about user", id2: "json document with info about user" }. It doesn’t really have any structure; there isn’t really an overall map of what the db looks like. You don’t set up a structure then deal with that like you would a relational db. You have collections of documents, and those documents are just blobs of JSON.

However, at some point, you may want a more definite structure for your data. You can kinda hack that together, but what Mongoose does is allows you to define that structure up front - so instead of the above, Mongoose

a. lets you define a schema like myUsers: { id: { name, age, etc... }, and
b. lets you interact with Mongo using that structure, as if you’re just dealing with JS objects.

You don’t need it, but it can be really useful to use as the interface for dealing with Mongo. I think you’re doing the right thing trying to understand just MongoDB first. By all means read up on Mongoose and try to get a feel for how it works though, that way you’ll be able to recognise when it would be useful - if something gets too hard to do in just Mongo, adding Mongoose as a layer inbetween your code and Mongo might be the answer.