Ember Data Store
Learn how Ember Data store is used to create, search, update, delete, and persist records.
Ember Data store is used to create, search, update, delete and persist the records. Let’s see how we can use the store.
Creating records
We can use the createRecord()
method to create a record. We need to specify the model for which we want to create a record and the attributes of that model with data. Let’s create a record for the product
model:
this.store.createRecord('product', {title: 'Test Product',desc: 'This is just a test description',price: 10,category: 'Men',imglink : 'Sample image link'});
Searching records
We have multiple options for searching a record. We can search single or multiple records. Similarly, we can query for single or multiple records.
Retrieving a single record
We can use the findRecord()
method to retrieve a single record. We need to specify the model of the record that we want to search and the record’s ID.
The findRecord()
method returns a promise. If the record isn’t in the store ...