EmberJS – Handling Metadata

Metadata

Metadata is data that is used for specific model or type instead of using record. The total number of records of the server will be stored in the metadata.

{
   "post": {
      "id": 1,
      "type": "type_name",
      "attributes": {
         "name": "group_name",
         "city": "city_name"
      }
      // ...
   },
   "meta": {
      "total": 100
   }
}

In the above code, meta represents the number of records in the store. The metadata can be accessed by using the following method −

store.query('post').then((myresult) => {
   let meta = myresult.get('meta');
})

The above process can be done by calling the store.query() method on the myresult. The total number of pages can be calculated by using meta.total.

Previous Page:-Click Here

Leave a Reply