49 lines
1.1 KiB
Nim
49 lines
1.1 KiB
Nim
import options, times, timeutils, uuids
|
|
|
|
type
|
|
User* = object
|
|
id*: UUID
|
|
displayName*: string
|
|
email*: string
|
|
hashedPwd*: string
|
|
|
|
ApiToken* = object
|
|
id*: UUID
|
|
userId*: UUID
|
|
name*:string
|
|
expires*: Option[DateTime]
|
|
hashedToken*: string
|
|
|
|
Measure* = object
|
|
id*: UUID
|
|
userId*: UUID
|
|
slug*: string
|
|
name*: string
|
|
description*: string
|
|
domainSource*: Option[string]
|
|
domainUnits*: string
|
|
rangeSource*: Option[string]
|
|
rangeUnits*: string
|
|
analysis*: seq[string]
|
|
|
|
Value* = object
|
|
id*: UUID
|
|
measureId*: UUID
|
|
value*: int
|
|
timestamp*: DateTime
|
|
extData*: string
|
|
|
|
proc `$`*(u: User): string =
|
|
return "User " & ($u.id)[0..6] & " - " & u.displayName & " <" & u.email & ">"
|
|
|
|
proc `$`*(tok: ApiToken): string =
|
|
result = "ApiToken " & ($tok.id)[0..6] & " - " & tok.name
|
|
if tok.expires.isSome: result &= " (expires " & tok.expires.get.formatIso8601 & ")"
|
|
else: result &= " (no expiry)"
|
|
|
|
proc `$`*(m: Measure): string =
|
|
return "Measure " & ($m.id)[0..6] & " - " & m.slug
|
|
|
|
proc `$`*(v: Value): string =
|
|
return "Value " & ($v.id)[0..6] & " - " & ($v.measureId)[0..6] & " = " & $v.value
|