dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 377 forks source link

hooks being called twice? #553

Open varsis opened 10 years ago

varsis commented 10 years ago

I couldn't find anything on this but it looks like all of my hooks are being called twice, and this is causing issues for me, as I insert data after save. Any ideas as to why this be happening?

dxg commented 10 years ago

Can you provide some sample code?

varsis commented 9 years ago
var Chat = db.define('chat', {
    title: string,
    date: Date
    } 
}, {
    hooks: { afterSave: function(err){
// This gets printed twice
   console.log('AfterSave Called');
}
});

var chat = new Chat.create({..data here..}, function(err,chat) {
// handle save here
});

The console log gets printed out twice.

varsis commented 9 years ago

I found the issue, however I don't know of any work around at the moment. What is happening is I have two models. One model contains the other and vice versa, however this is not done using the reverse that can be defined in a model (as it does not work with my setup)