views:

265

answers:

2

What's the best way to validate data being inserted or updated into Mongo?

Is it to wrote some sort of server executed Javascript code that does the validation?

Thanks

d

A: 

I think it would be normal for your app to handle this kind of thing. If the data is invalid in some way, don't let it get added to the datastore until the user has corrected whatever error you have detected.

Splash
A: 

MongoDB doesn't have constraints or triggers so the application has to validate the data.

You can also write Javascript scripts that check once a day or more if there is invalid data. You can use this to check the quality of the business logic of your application.

Theo