dresende / node-orm2

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

Removing items via chaining with a hasOne association. #526

Open jonahwh opened 10 years ago

jonahwh commented 10 years ago

Using express:

req.models.signup.findByEvent({shortName: req.param('shortName')}).remove(function(err){
    if(err) return next(err);
    res.send({});
});

err is null, but the rows are not removed from the database.

For sanity

req.models.signup.findByEvent({shortName: req.param('shortName')}, function(err, results){
    console.log(JSON.stringifiy(results));
});

Does return the rows I want to remove from the database.

Is this a bug? If not, how should I go about removing rows from the DB using association? Do I have to loop through the result set?