mongoose - Node.js rest api validate incoming json from url -
i have simple rest api excepts json in url through request.
i have mongoose schema , validate incoming json in correct format.
can mongoose alone?
yes, can create document parsed json using model , validate
.
// assuming having parsed json yet var doc = mymodel(json.parse(json_from_url)); doc.validate(function(err) {...});
note: mongoose queries validate document before saving database.
Comments
Post a Comment