EmberJS - 处理元数据
元数据是用于特定模型或类型的数据,而不是使用记录。服务器的记录总数将存储在元数据中。
{ "post": { "id": 1, "type": "type_name", "attributes": { "name": "group_name", "city": "city_name" } // ... }, "meta": { "total": 100 } }
在上面的代码中,meta 表示 store 中的记录数。可以使用以下方法 − 来访问元数据。
store.query('post').then((myresult) => { let meta = myresult.get('meta'); })
可以通过在 myresult 上调用 store.query() 方法来完成上述过程。可以使用 meta.total 来计算总页数。