getoutreach / epf

A framework for keeping your Ember.js apps in sync.
http://epf.io
MIT License
369 stars 33 forks source link

metadata support #70

Closed heartsentwined closed 10 years ago

heartsentwined commented 11 years ago

Does epf support accessing metadata, like this sample payload?

{
  "meta": 
  {
    "baz": "quux",
    "since": 12159837492
  },
  "foos": { }
}

Let say the above payload comes back from

session.query('foo', { search: 'bar' });

Can we have the metadata attached to the model array - e.g.

doSomething().then( function(models) {
  // maybe models.meta
  // or models.getMeta();
  // etc
});

Or perhaps another reasonable pattern is attaching to the master class - e.g.

App.Foo.meta
App.Foo.getMeta();
// ...

Although I'm leaning on the former, or at least some way to distinguish between different session.query() calls with different parameters.

Reference:

If you would like to add meta information to the outputted JSON, use the :meta option:

render json: @posts, serializer: CustomArraySerializer, meta: {total: 10}

The above usage of :meta will produce the following:

{
  "meta": { "total": 10 },
  "posts": [
    { "title": "Post 1", "body": "Hello!" },
    { "title": "Post 2", "body": "Goodbye!" }
  ]
}
  • Metadata support in emberjs/data#815 - although I don't think their implementation is neat. For instance, why force a developer to declare meta properties beforehand?

Edit:

ghempton commented 11 years ago

This currently works in some fashion, but I haven't figured out the final API. Over the next few days I am planning on baking in a paginated model collection to the framework (and allowing custom collections in general). At that time I will think this through.

heartsentwined commented 11 years ago

Alright, thanks in advance!

ghempton commented 10 years ago

Metadata on collections should be functioning now.