Search⌘ K
AI Features

Defining the Model for Our Application

Explore how to create and define a product model in Ember Data for your application. Understand setting up model attributes, using built-in data types, and creating custom transforms to handle data serialization and deserialization effectively.

The model class defines the behavior and properties of the data presented to the user. We need a product model for our e-commerce application that will define the properties of that product. Let’s create a product model.

Generating a model

We need to create a new JavaScript file in the app/models directory. We can either create it manually or use the following command:

ember g model product

This command generates a boilerplate for our model named product.js in app/models. Let’s open the product.js ...