I have some question about modeling in Perfect and using StORM (MySQL-StORM in my case).
Assume we have models named User
and Note
with these simple rules:
- Users have
id, firstName, lastName, age(optional)
- Notes have
id, title, content
- Users could have
Zero or more
notes. - Every note belongs to
One
user.
My questions are:
- What data-types does StORM support?
- How can I set
age
propertynull-able
in database? - How can I create relation between
User
andNote
?
something like this:
class User {
var id: UUID
var firstName: String
var lastName: String
var age: String? //this could be NULL-able,
var notes: [Note] //users notes
}
class Note {
var id: UUID
var title: String
var content: String
var owner: User //owner of the note
}
How can I implement this, using Perfect (Server-Side Swift) and MySQL-StORM?