2

I am learning Mongoose. As its documents said here "Everything in Mongoose starts with a Schema..." and the example:

var blogSchema = new Schema({
  title:  String,
  author: String,
  body:   String,
  comments: [{ body: String, date: Date }],
  date: { type: Date, default: Date.now },
  hidden: Boolean,
  meta: {
    votes: Number,
    favs:  Number
  }
});

I can't help but wonder what is the benefit of using it (and mongo) then. Because when I use "traditional" SQL, of course, I will start with schema, define all the columns to design my table. So my blog table will look basically the same as that blogSchema. Then why should I use mongoose (and the mongo) in the first place?

---- updated based some comments I got -----

This question Why do we need, what advantages to use mongoose is related to my question but not the same. I need to use nosql because I need to have a loosely structured data system during the stages of rapid development. But the way mongoose provides to use Mongo feels like old sql way, then why bother nosql. But the first comment I got has shed some light on it.

Qiulang
  • 10,295
  • 11
  • 80
  • 129
  • 1
    This "schema" is not as strict as one in, say, mysql. It's fluid as water. If you need to add another field to your blog, you add a line of code, restart your server and there's no step 3. Whereas in mysql, this means either bring down your app for the data migration, or jump through crazy hoops to avoid downtime. (on the plus side, in a relational db, you can be _sure_ about the shape of your data. Mongoose schema doesn't enforce/guarantee anything) – Sergio Tulentsev Jul 17 '17 at 05:42
  • Are you asking what are the main benefit to use MongoDB schema instead of another generic SQL Solution? – Daniele Tassone Jul 17 '17 at 07:20
  • Yes, what is the benefit of using mongoose. – Qiulang Jul 17 '17 at 07:22
  • @Qiulang MongoDB and Mongoose are two different think. Is't like SQLServer and Entity Framework. So, Mongoose is just one of the way to use MongoDB (another one is the native driver that i prefer). Then, are you asking MongoDB vs SQL generic schema design i suppose? – Daniele Tassone Jul 17 '17 at 07:33
  • "I need to use nosql because I need to have a loosely structured data system during the stages of rapid development" `ALTER TABLE` is your friend. It's not hard to do rapid changes in SQL. – Ben Jul 18 '17 at 13:35

0 Answers0