<commit_before>Along with the records returned from your store, you'll likely need to handle some kind of metadata. *Metadata* is data that goes along with a specific *model* or *type* instead of a record.

Pagination is a common example of using metadata. Imagine a blog with far more posts than you can display at once. You might query it like so:

```js
let result = this.get('store').query('post', {
  limit: 10,
  offset: 0
});
```

To get different *pages* of data, you'd simply change your offset in increments of 10. So far, so good. But how do you know how many pages of data you have? Your server would need to return the total number of records as a piece of metadata.

Each serializer will expect the metadata to be returned differently. For example, Ember Data's JSON deserializer looks for a `meta` key:

```js
{
  "post": {
    "id": 1,
    "title": "Progressive Enhancement is Dead",
    "comments": ["1", "2"],
    "links": {
      "user": "/people/tomdale"
    },
    // ...
  },

  "meta": {
    "total": 100
  }
}
```

Regardless of the serializer used, this metadata is extracted from the response. You can then read it with `.get('meta')`.

This can be done on the result of a `store.query()` call:

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

On a belongsTo relationship:

```js
let post = store.peekRecord('post', 1);

post.get('author').then((author) => {
  let meta = author.get('meta');
});
```

Or on a hasMany relationship:

```js
let post = store.peekRecord('post', 1);

post.get('comments').then((comments) => {
  let meta = comments.get('meta');
});
```

After reading it, `meta.total` can be used to calculate how many pages of posts you'll have.

To use the `meta` data outside of the `model` hook, you need to return it:

```app/routes/users.js
import Ember from 'ember';

export default Ember.Route.extend({
  model() {
    return this.store.findAll('user').then((results) => {
      return {
        users: results,
        meta: results.meta
      };
    });
  },
  
  setupController(controller, { users, meta }) {
    this._super(controller, users);
    controller.set('meta', meta);
  }
});
```

To customize metadata extraction, check out the documentation for your serializer.<commit_msg>Fetch meta through .get, as required<commit_after>Along with the records returned from your store, you'll likely need to handle some kind of metadata. *Metadata* is data that goes along with a specific *model* or *type* instead of a record.

Pagination is a common example of using metadata. Imagine a blog with far more posts than you can display at once. You might query it like so:

```js
let result = this.get('store').query('post', {
  limit: 10,
  offset: 0
});
```

To get different *pages* of data, you'd simply change your offset in increments of 10. So far, so good. But how do you know how many pages of data you have? Your server would need to return the total number of records as a piece of metadata.

Each serializer will expect the metadata to be returned differently. For example, Ember Data's JSON deserializer looks for a `meta` key:

```js
{
  "post": {
    "id": 1,
    "title": "Progressive Enhancement is Dead",
    "comments": ["1", "2"],
    "links": {
      "user": "/people/tomdale"
    },
    // ...
  },

  "meta": {
    "total": 100
  }
}
```

Regardless of the serializer used, this metadata is extracted from the response. You can then read it with `.get('meta')`.

This can be done on the result of a `store.query()` call:

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

On a belongsTo relationship:

```js
let post = store.peekRecord('post', 1);

post.get('author').then((author) => {
  let meta = author.get('meta');
});
```

Or on a hasMany relationship:

```js
let post = store.peekRecord('post', 1);

post.get('comments').then((comments) => {
  let meta = comments.get('meta');
});
```

After reading it, `meta.total` can be used to calculate how many pages of posts you'll have.

To use the `meta` data outside of the `model` hook, you need to return it:

```app/routes/users.js
import Ember from 'ember';

export default Ember.Route.extend({
  model() {
    return this.store.findAll('user').then((results) => {
      return {
        users: results,
        meta: results.get('meta')
      };
    });
  },
  
  setupController(controller, { users, meta }) {
    this._super(controller, users);
    controller.set('meta', meta);
  }
});
```

To customize metadata extraction, check out the documentation for your serializer.
{'fraction_non_alphanumeric': 0.13854895104895104, 'fraction_numerical': 0.005681818181818182, 'mean_word_length': 3.563310069790628, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6193858', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1359, 'n_words': 566}