Hi,
As mention in https://v2.ottomanjs.com/guides/document.html#updating,
The
save()function is generally the right way to update a document with Ottoman. Withsave(), you get full validation and middleware.
The validation of field name is not working. Expected an error on the field name firstNames but resulted in saving into database.
const User = ottoman.model(
"User",
{
firstName: String,
lastName: String,
email: String,
tagline: String,
hide: Boolean,
dob: Date,
},
{ idkey: "id" }
);
const tom = new User({
id: "a2",
firstNames: "Major",
lastName: "Tom",
email: "major.tom@acme.com",
tagLine: "Send me up a drink",
});
const runAsync = async () => {
try {
await tom.save();
console.log(`success: user ${tom.firstNames} added!`);
} catch (err) {
throw err;
}
};