I have a hasOne relationship and want to query based on the referenced table.
var Person = db.define('person', {
name : String
});
var Animal = db.define('animal', {
name : String
});
Animal.hasOne("owner", Person); // creates column 'owner_id' in 'animal' table
I want to do do something like:
SELECT * FROM animal JOIN person ON animal.owner_id = person.id WHERE person.name = "John";
Any ideas how I can achieve this? In the drivers there is opts.merge that seems to be exactly what I am searching for, but I can not find any documentation of it.
I already tried to pass find the options "__merge" and "extra", but ended up in a rather complex statement and failed to pass the condition.
It would be great if I could just do:
Animal.find(owner: Person.find("name": "John"))
I have a hasOne relationship and want to query based on the referenced table.
I want to do do something like:
Any ideas how I can achieve this? In the drivers there is
opts.mergethat seems to be exactly what I am searching for, but I can not find any documentation of it.I already tried to pass
findthe options "__merge" and "extra", but ended up in a rather complex statement and failed to pass the condition.It would be great if I could just do: