15.09.2017 Views

the-magical-marvels-of-mongodb-slides

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

What About Insert Validations?<br />

If we were to insert a new potion but accidentally set <strong>the</strong> price value to a string, <strong>the</strong> potion<br />

would still get saved despite all o<strong>the</strong>r potions having integer values.<br />

> db.potions.insert({<br />

"name": "Invisibility",<br />

"vendor": "Kettlecooked",<br />

"price": "Ten dollars",<br />

"score": 59<br />

})<br />

WriteResult({ "nInserted": 1 })<br />

The document still got saved<br />

to <strong>the</strong> database!<br />

SHELL<br />

Data we might consider to be<br />

invalid but MongoDB will<br />

think is fine

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!