Model API (GNU Artanis web-framework Manual)

Previous: , Up: Models [Contents]

12.2.4 Model API

The model definition API:

(create-artanis-model model_name (:deps deps_list ...) fields_def ...)

The fields_def syntax is:

(field_name type (options ...))

  1. Field Type

    To unify API amoung all the DB backend supported by GNU Artanis, we provide abstract types:

    • auto: auto incremental index
    • tiny-integer:
    • small-integer:
    • big-integer: 0~2^64
    • text: long text
    • boolean:
    • float
    • double
    • char-field: varchar
      • you need to specify #:maxlen positive_integer in the options.
    • date-field
      • These options imply #:no-edit)
      • #:auto-now
      • #:auto-now-once

    NOTE: if these types can’t meet your requirements, just write the known type for your configured DB backend supported types, it will be passed directly to the backend, however, without the framework specific feature like type checking.

    The options has specific syntax for different DB backend.

  2. MySQL/MariaDB options

    The specific options are:

    • #:not-null
    • #:null
    • #:default to speficy default value.
    • #:unique
    • #:unique-key
    • #:primary-key
    • #:key to specify keys.
    • #:auto-incremental
    • #:comment for commenting.
    • #:column-format
    • #:storage mode DISK or MEMORY mode.
    • #:signed
    • #:unsigned
    • #:zerofill
  3. PostgreSQL options

    PostgreSQL migration hasn’t been supported yet…patches are welcome.

  4. SQLite3 options
    • #:not-null
    • #:null
    • #:default value
    • #:unique
    • #:unique-key
    • #:primary-key
    • #:key
    • #:auto-increment
    • #:auto-now-once for timestamp.

AltStyle によって変換されたページ (->オリジナル) /