Skip to content

Reimplement the relation API #40

@rafinskipg

Description

@rafinskipg

Right now the relation API is inconsistent:

A) It does emit POST methods instead of PUT to corbel relation api
B) It does not allow to create custom named relations

  • Explanation of why this is bad :

    corbelDriver.resources
      .relation('sourceResourceName', sourceResourceId, 'destResourceName')
    

    This is making mandatory the creation of a relation called sourceResourceName_destResourceName, but this is not the same functionality that corbel provides. Instead we should allow to use custom named relations.

I suggest this other way around for the reimplementation, let me see which are your thoughts

corbelDriver.resources.relation({
  id : CAR_ID,
  resource : 'cars',
  relationName : 'coolPeople',
})
.add({
  resource : 'people',
  id : PERSON_ID
}, {
  extra : 'data'
});


corbelDriver.resources.relation({
  id : CAR_ID,
  resource : 'cars',
  relationName : 'coolPeople'
})
.add(null, {
  customData: customData
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions