Open
Description
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
}