EmberJS - 元資料處理



元資料是用於特定模型或型別而不是使用記錄的資料。伺服器的記錄總數將儲存在元資料中。

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

在以上程式碼中,meta 表示儲存中的記錄數。可使用以下方法訪問元資料 −

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

可透過在 myresult 上呼叫 store.query() 方法完成以上流程。可使用 meta.total 計算頁面總數。

emberjs_model.htm
廣告
© . All rights reserved.