Here's an example of a DB schema definition (from 
[https://github.com/moigagoo/norm-sample-webapp/blob/develop/src/models.nim)](https://github.com/moigagoo/norm-sample-webapp/blob/develop/src/models.nim\)):
    
    
    db("app.db", "", "", ""):
      type
        Owner* = object
          firstName*: string
          lastName*: string
          birthDate* {.
            dbType: "INTEGER",
            parseIt: it.parseInt().fromUnix().utc(),
            formatIt: $it.toTime().toUnix()
          .}: DateTime
      
      proc getOwnerById(id: string): Owner =
        result = Owner(birthDate: now())
        withDb:
          result.getOne parseInt(id)
      
      type
        Pet* = object
          name*: string
          birthDate* {.
            dbType: "INTEGER",
            parseIt: it.parseInt().fromUnix().utc(),
            formatIt: $it.toTime().toUnix()
          .}: DateTime
          owner* {.
            dbCol: "ownerId",
            dbType: "INTEGER",
            fk: Owner
            parser: getOwnerById,
            formatIt: $it.id
          .}: Owner
    
    
    Run

Reply via email to