Open plwalters opened 9 years ago
I think I'd have to wire up the parent ids in the json results adapter if I chose to go that route.
If you show me a JSON data sample of a few related "entities", I might have some ideas. What are these entities anyway?
It's the swapi.co API serving Star Wars data :)
{
"birth_year": "19 BBY",
"eye_color": "Blue",
"films": [
"http://swapi.co/api/films/1/",
...
],
"gender": "Male",
"hair_color": "Blond",
"height": "172",
"homeworld": "http://swapi.co/api/planets/1/",
"mass": "77",
"name": "Luke Skywalker",
"skin_color": "Fair",
"created": "2014-12-09T13:50:51.644000Z",
"edited": "2014-12-10T13:52:43.172000Z",
"species": [
"http://swapi.co/api/species/1/"
],
"starships": [
"http://swapi.co/api/starships/12/",
...
],
"url": "http://swapi.co/api/people/1/",
"vehicles": [
"http://swapi.co/api/vehicles/14/"
...
]
}
which might have some related starships -
{
"MGLT": "10 MGLT",
"cargo_capacity": "1000000000000",
"consumables": "3 years",
"cost_in_credits": "1000000000000",
"created": "2014-12-10T16:36:50.509000Z",
"crew": "342953",
"edited": "2014-12-10T16:36:50.509000Z",
"hyperdrive_rating": "4.0",
"length": "120000",
"manufacturer": "Imperial Department of Military Research, Sienar Fleet Systems",
"max_atmosphering_speed": "n/a",
"model": "DS-1 Orbital Battle Station",
"name": "Death Star",
"passengers": "843342",
"films": [
"http://swapi.co/api/films/1/"
],
"pilots": [],
"starship_class": "Deep Space Mobile Battlestation",
"url": "http://swapi.co/api/starships/9/"
}
The issue I see with why this won't work with Breeze.js is because the references are backwards to the traditional references. The parent references it's children instead of the other way around.
I'm cool that we're not dealing with a relational source. Many sources aren't.
I suspect you're looking at a read-only source. If not, talk to me and we can apply a variation of the Abstract REST Adapter in Breeze Labs.
As for modeling, I think I know what I'd do:
filmsUrl
, speciesUrl
, etc).JsonResultsAdapter
that morphed nodes to the actual JSON field names. This could be driven by custom metadata or, perhaps better, driven by property naming conventions (e.g., metadata property names ending in 'Url').EntityType
s for the corresponding objects that I'll be using in my demo (e.g. Film
, Species
).Object.definedProperty
for each "navigation" (xxx
from set {film, species, ...}) that uses the xxxUrl
array to deliver instances of the related xxx
entity from Breeze cache. Again this could be driven by convention.xxx
property itself populate the result async ... a kind of lazy load. Breeze doesn't do lazy loading (for good reasons) so this might seem weird; could fall back to an "eager fetch" or a "fetch-on-demand" approach.All of this is fun speculation. It depends upon what you're really trying to achieve and whether you think we'd be demonstrating value with these kinds of games.
Would like to add Breeze.js to manage caching and use as a fun aurelia sample but the data structure isn't typical of relational data. Any ideas @wardbell ?
I could add a json results adapter but it feels like it could get unwieldy quickly and might be not the best for a community sample.