mardi 19 avril 2016

Recommended pattern to implement global Search with multiple Objects type (Ember 2 JSONAPI)

I am new to Ember and I will like to implement a server side search endpoint that returns results for several models/tables in DB.

Trying to figure out what is the best practice to do this in Ember. Server results can contain several types of objects/models, each model is already defined in ember-data.

So far I am able to retrieve the results (I can see the results in ember-inspector) but I am not able to render it properly (I only have access to first object for some reason).

Current architecture:

  • rails-5 server with JSONAPI response
  • ember 2.3 with multiple models

Flow:

  1. POST /search with body:

    {"search":{"query": "xxx","size": "10"}}

  2. RESULT:

    { "data": [ { "id": "111111", "type": "foo", "attributes": { "x": "y" } }, { "id": "222222", "type": "bar", "attributes": { "z": "y" } } ] }




Aucun commentaire:

Enregistrer un commentaire