Within my Ember.js application, I have a model named emails
structured as follows:
import DS from 'ember-data';
export default DS.Model.extend({
label : DS.attr('string'),
primary : DS.attr('string'),
email : DS.attr('string')
});
To populate the model with data retrieved from the server, I use the following code snippet:
this.store.createRecord('emails', {
label: 'Foo',
primary: true,
email: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="01676e6e416360732f626e6c">[email protected]</a>
});
Users have the ability to add new emails to the store through a form. When a new primary email is added, any existing primary email should be switched to false before adding the new record.
I attempted to access all records using this.store.peekAll('emails')
in order to update the one with primary: true
, but I am unsure of the correct method. How can I achieve this task?
It is worth noting that I am not utilizing the REST Adapter, hence I cannot utilize Ember Data queries as outlined in this guide.