These are chat archives for Automattic/mongoose

11th
Jun 2015
Fayi Femi-Balogun
@fayimora
Jun 11 2015 10:44
Hello, I have this in my schema
email: { address: {type: String, required: true, unique: true}, verified: {type: Boolean, default: true} },
however, the verified field is never persisted to the db :cry:
Eloy Toro
@eloytoro
Jun 11 2015 14:56
@vkarpov15 How do I fully validate a doc before saving it? In my model there are some collections that share a 1-to-1 strict relation in which either both docs exist or neither does, but sometimes doing async operations validation might fail for any of the documents being saved or updated. Im getting around this Im manually removing the docs in case any error occurs. The validatemethod doesn't seem to help, it checks for most validations except for unique constrains.
To summarize I wish there could be a way I could check and catch errors for docs before I proceed to persist them into the DB