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

peekRecord() not working as expected #4985

Closed
denchen opened this issue May 12, 2017 · 6 comments
Closed

peekRecord() not working as expected #4985

denchen opened this issue May 12, 2017 · 6 comments

Comments

@denchen
Copy link

denchen commented May 12, 2017

I'm having an issue with peekRecord(), and I'm hoping I'm just not understanding how it works.

Basically, I have a record that I want to destroy, but after I destroy it and then use peekRecord() on it, I still see the record. Is this expected? In essence, I'm doing this:

try {
  let record = this.store.peekRecord('my-model', 123);
  if (record) {
    yield record.destroyRecord();
    // I expect this next command to return null or Record Not Found
    let record2 = this.store.peekRecord('my-model', 123);
    console.debug('Record is still here:', record2.get('id'));
  }
} catch(e) {
  console.error('Error:', e);
}

I'm using ember-cli 2.12.3.

@hjdivad
Copy link
Member

hjdivad commented May 16, 2017

@denchen the deletion has not been persisted yet.

record.destroyRecord.then(() => {
  store.hasRecordForId('model-name', id);
})

@stefanpenner
Copy link
Member

@hjdivad wouldn't the yield handle that? (Assuming the generator supports promises)

@pangratz
Copy link
Member

pangratz commented Oct 7, 2017

The record is in the root.deleted.saved state, see this twiddle.

@runspired
Copy link
Contributor

I believe this has been cleaned up, but we should confirm.

@sly7-7
Copy link
Contributor

sly7-7 commented Mar 19, 2018

@rwjblue @bmac I can't test the previous twiddle against ember-data canary, because of this error:

ember-data.js:258 Uncaught Error: Could not find module `@ember/ordered-set` imported from `ember-data/-private/system/ordered-set`

Something wrong with the external import ? must we add something somewhere?

@runspired So I tested the twiddle against beta, and the destroyed record is still in the store. (unloadRecord works btw)

@runspired
Copy link
Contributor

Closing in favor of #5006 which is a duplicate: TL;DR destroyed records are not unloaded automatically.

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

6 participants