Skip to content

Multiple parents for nested urls (re-issued from https://github.com/js-data/js-data-angular/issues/250) #55

@t-richter

Description

@t-richter

Hi,
I have a special use-case, where multiple belongsTo are needed.
In our data-model, where we don't know the hierarchy-depth of nested elements in advance, so we use a 'general' entity, that is nested in 'itself'. We have an additional 'type' entity, defining the nodes special attributes, like this:

name: 'Entity',
endpoint: 'entities.json',

relations:
{
    belongsTo:
    {
        Entity:
        {
            localField: 'parent',
            localKey: 'parentId',
            parent: false
        },
        EntityType:
        {
            localField: 'type',
            localKey: 'typeId'
        }
    },
    hasMany:
    {
        Entity:
        {
            localField: 'children',
            foreignKey: 'parentId'
        }
}

I didn't find a clue in the docs this wouldn't work, but unfortunately it doesn't seem to do so.
It produces an error:

Entity RuntimeError Object
  37.defaultsPrototype.error    
  37.defaultsPrototype.errorFn  
  _inject   
  _inject   
  inject    
  (anonymous function)  
  processResults    
  (anonymous function)  
  deferred.promise.then.wrappedCallback 
  (anonymous function)  
  $get.Scope.$eval  
  $get.Scope.$digest    
  $get.Scope.$apply 
  done  
  completeRequest   
  xhr.onreadystatechange    
Entity RuntimeError Object
  37.defaultsPrototype.error    
  37.defaultsPrototype.errorFn  
  _inject   
  _inject   
  inject    
  (anonymous function)  
  processResults    
  (anonymous function)  
  deferred.promise.then.wrappedCallback 
  (anonymous function)  
  $get.Scope.$eval  
  $get.Scope.$digest    
  $get.Scope.$apply 
  done  
  completeRequest   
  xhr.onreadystatechange    
Entity RuntimeError Object
  37.defaultsPrototype.error    
  37.defaultsPrototype.errorFn  
  _inject   
  _inject   
  inject    
  (anonymous function)  
  processResults    
  (anonymous function)  
  deferred.promise.then.wrappedCallback 
  (anonymous function)  
  $get.Scope.$eval  
  $get.Scope.$digest    
  $get.Scope.$apply 
  done  
  completeRequest   
  xhr.onreadystatechange    
TypeError: Cannot read property 'id' of undefined

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions