neumino / thinky

JavaScript ORM for RethinkDB
http://justonepixel.com/thinky/
Other
1.12k stars 128 forks source link

Model.post('validate' function being called twice (bug) #581

Closed nodesocket closed 7 years ago

nodesocket commented 7 years ago

Using the Model.post('validate' hook with a custom function, I noticed it is being called twice when invoked with a single new Model.

Model.post('validate', function(next) {
    console.log('in Model post validate'); // printed twice
    return next();
});

You'll see the console.log() twice.

neumino commented 7 years ago

I guess what you mean is that the hook is called twice when you save a document. There's one validation happening before saving, and one after on retrieve.

So that's working as intended.

nodesocket commented 7 years ago

How then do I only have the hook called before saving? Is that possible.