What is the best way to validate data in mongo?

后端 未结 5 1471
后悔当初
后悔当初 2020-12-06 11:39

What\'s the best way to validate data being inserted or updated into MongoDB? Is it to write some sort of server executed Javascript code that does the validation?

5条回答
  •  生来不讨喜
    2020-12-06 11:42

    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.

提交回复
热议问题