-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Init entities and relationships #12
Comments
I think we should aim for usability here. If I want to use this one:
Means that I also need to specify a second init method in user, right? Is that what we want? It also means that I already have to create friend objects (that seems ok). Would we also need to pick different random friends for each user or we don't care about repeating (this is not that important for now, probably) Also, how about hiding the database implementation details as much as possible? @zzarcon proposed to only use the server for object creation, which will then forward those calls to the internal db. Then the db might only be used in the closure as a passed in parameter. |
@joanromano that closure was just an example and should not be required to use it if init(id:) is enough, so we are not forcing to have that init. |
But if they need relationships we then force to have two inits |
No we don't in User.init(id:) they just have to call Friend.init(id:) |
So what is |
Another example using the closure if fake data is not enough (e.g creating a user from ui should have a nane entered by the user) |
Reverse and recursive relationships are not part of this discussion see #16 |
struct B: Storable {
let id: Int
init(id: Int, db: KakapoDB) {
self.id = id
}
}
struct A: Storable {
let id: Int
let b: B
init(id: Int, db: KakapoDB) {
self.id = id
self.b = db.create(B)[0]
}
} |
or: self.b = sutt.insert { (id) -> B in
return B(id: id)
} |
Every entity that conform to the protocol (ATM called
KakapoSerializable
) will have to implementinit(id: String)
. To create entities there might be 2 ways:Friends is a relationship od User:
User will init is relationship as:
The text was updated successfully, but these errors were encountered: