Skip to content

Inject relations for parent resource on create #132

Closed
@Patrik-Lundqvist

Description

@Patrik-Lundqvist

When creating a new item that belongs to a another resource, the parent resource doesn't seem to get updated with the relation.

Example:

DS.defineResource({
name: 'user',
relations: {
    belongsTo: {
        organization: {
            localKey: 'organizationId',
            localField: 'organization'
        }
    }
}
});

DS.defineResource({
name: 'organization',
relations: {
    hasMany: {
        user: {
            localField: 'users',
            foreignKey: 'organizationId'
        }
    }
}
});

Creating item

DS.create('users', { name: 'test', organizationId: 1}).then(function() {
    DS.get('organization', 1); // This will not contain a relation to the newly created user
});

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions