1

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:

  1. What data-types does StORM support?
  2. How can I set age property null-able in database?
  3. How can I create relation between User and Note?

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?

Omid Golparvar
  • 468
  • 5
  • 12

0 Answers0