Announcement

Collapse
No announcement yet.

EntityDefs and links

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • EntityDefs and links

    Hi, I'm having some problems with my custom module, I have 2 entities: Article and ArticleControl with this definitions:

    Article:
    PHP Code:
    {
        
    "fields": {
            
    "name": {
                
    "type""varchar",
                
    "required"true
            
    },
            
    "createdAt": {
                
    "type""datetime",
                
    "readOnly"true
            
    },
            
    "modifiedAt": {
                
    "type""datetime",
                
    "readOnly"true
            
    },
            
    "createdBy": {
                
    "type""link",
                
    "readOnly"true
            
    },
            
    "modifiedBy": {
                
    "type""link",
                
    "readOnly"true
            
    },
            
    "assignedUser": {
                
    "type""link",
                
    "required"true
            
    },
            
    "teams": {
                
    "type""linkMultiple"
            
    }
        },
        
    "links": {
            
    "createdBy": {
                
    "type""belongsTo",
                
    "entity""User"
            
    },
            
    "modifiedBy": {
                
    "type""belongsTo",
                
    "entity""User"
            
    },
            
    "assignedUser": {
                
    "type""belongsTo",
                
    "entity""User"
            
    },
            
    "teams": {
                
    "type""hasMany",
                
    "entity""Team",
                
    "relationName""EntityTeam"
            
    },
            
    "tasks": {
                
    "type""belongsTo",
                
    "entity""Task"
            
    },
            
    "control": {
                
    "type""hasChildren",
                
    "entity""ArticleControl",
                
    "foreign""parent"
            
    }
        },
        
    "collection": {
            
    "sortBy""name",
            
    "asc"false,
            
    "boolFilters": ["onlyMy"]
        }

    ArticleControl:
    PHP Code:
    {
        
    "fields": {
            
    "data": {
                
    "type""text"
            
    },
            
    "status": {
                
    "type""enum",
                
    "options": ["Pending""Completed"],
                
    "default""Pending"
            
    },
            
    "createdAt": {
                
    "type""datetime",
                
    "readOnly"true
            
    }
        },
        
    "links": {
            
    "control": {
                
    "type""belongsTo",
                
    "entity""Article"
            
    }
        },
        
    "collection": {
            
    "sortBy""createdAt",
            
    "asc"false
        
    }


    The issue is when I call /Article/%ID%/control I always get all the items instead of the items connected. What I'm missing?

    Thanks
    Last edited by caffeine; 09-28-2014, 07:34 PM.

  • #2
    Hi

    In Article you should have:

    PHP Code:
            "controls": {
                
    "type""hasMany",
                
    "entity""ArticleControl",
                
    "foreign""article"
            

    In ArticleControl

    PHP Code:
            "article": {
                
    "type""belongsTo",
                
    "entity""Article",
                
    "foreign""controls"
            

    Comment


    • #3
      Uff Thanks!!!!! it's working now.

      Comment

      Working...
      X