node-orm2 icon indicating copy to clipboard operation
node-orm2 copied to clipboard

how query fild fields form two table when I use hasOne ?

Open hacke2 opened this issue 10 years ago • 1 comments

I had use hasOne get Pet,e.g:

Animal.hasOne('owner', Person, {reverse: 'pets'})
Person(1).getPets(function(err, pets) {
            console.log(pets);
});

I want through one sql query Animal's fields, can I ?

like this sql:

SELECT person.name, animal.name FROM Person as person, Animal as animal WHERE animal.owner_id = person.id

hacke2 avatar Aug 27 '15 03:08 hacke2

How many queries does the above generate?

dxg avatar Aug 27 '15 15:08 dxg