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

Multiple references to the same object in an array only get loaded once in .loadMany() #5

Closed
scottwrobinson opened this issue Jul 1, 2015 · 0 comments

Comments

@scottwrobinson
Copy link
Owner

This issue happens when an object has an array of references and there are multiple references to the same object in the array.

In the code below, we give the user two references to the same Eye, but when we load the user there is only one reference there.

class Eye extends Document {
    constructor() {
        super('eyes');
        this.color = String;
    }
}

class User extends Document {
    constructor() {
        super('users');
        this.eyes = [Eye];
    }
}

var user = User.create();
var eye = Eye.create({color: 'blue'});

eye.save().then(function(e) {
    user.eyes.push(eye, eye);
    return user.save();
}).then(function(u) {
    return User.loadMany({});
}).then(function(users) {
    expect(users[0].eyes).to.have.length(2);    // FAILS
});
scottwrobinson added a commit that referenced this issue Jul 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant