Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'hasOne' association cannot get relate objects with some options #147

Closed
veilevil opened this issue May 3, 2013 · 5 comments
Closed

'hasOne' association cannot get relate objects with some options #147

veilevil opened this issue May 3, 2013 · 5 comments

Comments

@veilevil
Copy link

veilevil commented May 3, 2013

Guys,
I have problems about get relate objects in a Many-to-One relationship
this is my code:

    var Pet = db.define('pet', {
        name : String
    });
    var Person = db.define('person', {
        name : String
    });
    Pet.hasOne("owner", Person, {
        reverse : "pets"
    });
    Person(1).getPets({},{offset:0},function (err, pets) {
        res.send(pets);
    });

It seems enter into an infinite loop

If I fix my code like this

Person(1).getPets({},function (err, pets) {}

It runs ok.

and if use the 'many to many' association ,like this:

    Pet.hasManay("owners", Person, {
        reverse : "pets"
    });
    Person(1).getPets({},{offset:0},5,['name','z'],function (err, pets) {
        res.send(pets);
    });

It's ok too.

@dresende
Copy link
Owner

dresende commented May 3, 2013

I'm not sure if this is related to #144 but I'm going to check it out.

@dresende
Copy link
Owner

dresende commented May 3, 2013

Please try the latest commit. I pushed a fix for the mentioned issue that I think it should solve this.

@jogly
Copy link
Collaborator

jogly commented May 6, 2013

I ran into an infinite loop using a one-to-many relationship (A.hasOne(B)) with {reverse: true, autoFetch: true} using the latest official release. I replaced orm with the latest from git and the issue was resolved. Not an extensive test, but hopefully positive feedback.

@dresende
Copy link
Owner

dresende commented May 6, 2013

Thank you for your feedback. I'll just see if @veilevil gives some feedback in the short term.

@dresende
Copy link
Owner

dresende commented May 7, 2013

I'll close this, since I think it's solved and @leechfarm also confirmed it. If you have any more problems with this please reopen.

@dresende dresende closed this as completed May 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants