src/snorlogue/frontend/modelAnalysisService

Source   Edit  

A collection of procs related to analysing Model-types at compile time or extracting Metadata from them. Mostly necessary because you can't story a list of types or the like anywhere. This all data needed later must be extracted immediately when the Model is provided.

Types

ModelMetaData = object
  name*: string
  table*: string
  url*: string
Source   Edit  

Procs

proc checkForModelFields[T: Model](modelType: typedesc[T]) {.compileTime.}
Compiletime check if a given modelType contains any nested model fields. These can not be allowed, as this would mean supporting the creation of multiple model-entries in a database from one POST request, which is currently out of scope for this package. Source   Edit  
proc extractMetaData[T: Model](urlPrefix: static string; modelType: typedesc[T]): ModelMetaData {.
    compileTime.}
Source   Edit  
proc getForeignKeyFields[T: Model](modelType: typedesc[T]): seq[string] {.
    compileTime.}
Extracts the names of all foreign key fields from a model. Source   Edit  
proc validateModel[T: Model](model: typedesc[T]) {.compileTime.}
Compiletime check if the given model fulfills all requirements for being used with this package. Source   Edit