How to get metaData of model?

I feel very frustrated for get model metadata. When I use metadataFor(modelName), I got a warning message, says

store.metadataFor()` has been deprecated. You can use `.get('meta')` on relationships and arrays returned from `store.query()`

and when the model change, the meta change to undefined, so I use the store.query() result to .get('meta'), but I got nothing!!

This is the data return from server:

{
  posts: [
    {
        id: 1,
        topic: 'some topic'
    },
   {
        id: 2,
        topic: 'some topic'
    },
   {
        id: 3,
        topic: 'some topic'
    },
  ],
  meta: {
    total: 10
  }
}

Please help me !

Have you seen these issues? 3419 and 2905

It seems that the solution for the time being is to go back to using metadataFor() and ignore the warning.

yes, but it seems there are nothing helpful :cry: .

I’ve come to the conclusion that the metadata stuff is broken at the moment. The only way I can get it to work at all is using deprecated/private functions and even then it is hacky.

@mark_duan, not for result of store.query(‘posts’), but to the then function of returned promise:

  this.get('store').query('post', {}).then((result) => { console.log(result.get('meta'))})
1 Like