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

Support a more complete rollback of records #3536

Closed
forgetboy opened this issue Jul 13, 2015 · 1 comment
Closed

Support a more complete rollback of records #3536

forgetboy opened this issue Jul 13, 2015 · 1 comment

Comments

@forgetboy
Copy link

I would propose we do something along these lines to provide a more comprehensive rollback -

rollback(record) {
           if (!record) {
        return;
    }

    record.eachRelationship((name, descriptor) => {
        if (descriptor.kind === 'hasMany') {
            let hasManyRecords = record.get(name);
            let hasManyRecordsSize = hasManyRecords.length;
            for (let i = hasManyRecordsSize - 1; i >= 0; i--) {
                this.rollback(hasManyRecords.objectAt(i));
            }
        } else if (descriptor.kind === 'belongsTo') {
            this.rollback(record.get(name));
        }
    });

    record.rollbackAttributes();
}
@wecc
Copy link
Contributor

wecc commented Oct 22, 2016

I'm closing this as we're tracking dirtyness/rollback of relationships in emberjs/rfcs#21

@wecc wecc closed this as completed Oct 22, 2016
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

2 participants