node.js - Isn't mongoose contradictory to nosql? -


i've watched many videos , tutorials on mongodb , mongoose, , while think mongoose it's job well, isn't contradictory flexibility nosql datastore offers? being schema-less environment.

what if want add new property, or array document? have update mongoose schema correct? seems counter-intuitive whole point of flexible document store.

if want application more flexible, isn't mongoose wrong choice application?

disclaimer: i've been using mongoose 2 years in large enterprisey application, , have been using mongo year on top of pre-mongoose.

the docs mention

let's face it, writing mongodb validation, casting , business logic boilerplate drag. that's why wrote mongoose.

this statement hard appreciate unless you've been through pain.

here's dream: application perfect, , store need in 1 collection. can throw data or fetch it. fits linux pipeline , works!

i think reality underestimate our data at least relational , implications has. applications treat mongo/nosql de-normalized datastore: faster, simpler (to use) database can put full objects graphs , read them quickly. incredibly easy use compared sql + orm. genuinely blown away while.

however, application develops, little things start more complicated...

in order keep embedded data other collections in sync, need handle @ application level. means whenever save thing a, may need update things b , c somewhere else. example: user comments: you'd want embed basic user objects each comment.

as time goes on, definition of things a, b , c change , evolve application grows.

combine loosely-typed language, , it's easy accidentally save empty string instead of null, or null instead of undefined. best case. usually, these small little errors make caught , cause error. saved database forever, without knowing slipped up. until application crashes, because data wrong. after fix few of these, start program defensively. small changes hard , of higher-risk.

while can roll own (anything), adding small safety net between application code , database idea. it's nice know id column means thing. or when saved, guaranteed have checks x, y , z met.

or when change username, updates comments.

the validation, query builder, pre/post save hooks, populations, , other goodies mongoose provides going save lots of pain.

at end of day, need balance effort want put in correctness comfortable with. while i've gotten lot of value out of plain mongo access, having mongoose has been nice stop-gap between mongo , full blown sql/orm combination.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -