Skip to content

Reverse and recursive Relantionships #16

Open
@MP0w

Description

@MP0w

Won't have to be implemented now
We may need it to avoid boilerplate and duplicated structs.
For the serialization might be easy:

struct User {
    let friends: [User]
}

During serialization we have to make sure that friends for User's inside friends is not serialized.
For creation might get more tricky because we can't provide the relationships at initialization time.

Current downsides:
To support /user/:id
You need to create two entities

struct Friend {
    let userId
    let friendId
}
struct User {
    let userId
    let friends: [Friend]
}

Gets even worst with user and friendships you need 4 entities to support /user/:id and /friendship/:id

// for /user/:id
struct Friendship {
    let userId
    let friendshipId
}
struct User {
    let userId
    let friendships: [Friendship]
}
// for /friendship/:id
struct Friendship2 {
    let user: User
    let friendshipId
}
struct User2 {
    let userId
    let friendshipId
}

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