Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the mito Reference Manual, version 0.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Thu Mar 11 14:13:42 2021 GMT+0.
• Introduction | What mito is all about | |
• Systems | The systems documentation | |
• Modules | The modules documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
Mito is yet another object relational mapper, and it aims to be a successor of Integral.
id
(serial/uuid primary key), created_at
and updated_at
by default like Ruby's ActiveRecordThis software is still ALPHA quality. The APIs likely change.
This software should work fine with MySQL, PostgreSQL and SQLite3 on SBCL/Clozure CL.
(mito:connect-toplevel :mysql :database-name "myapp" :username "fukamachi" :password "c0mon-1isp")
;=> #<DBD.MYSQL:<DBD-MYSQL-CONNECTION> {100691BFF3}>
(mito:deftable user ()
((name :col-type (:varchar 64))
(email :col-type (or (:varchar 128) :null))))
;=> #<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::USER>
(mito:table-definition 'user)
;=> (#<SXQL-STATEMENT: CREATE TABLE user (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(64) NOT NULL, email VARCHAR(128))>)
(mito:deftable tweet ()
((status :col-type :text)
(user :col-type user)))
;=> #<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::TWEET>
(mito:table-definition 'tweet)
;=> (#<SXQL-STATEMENT: CREATE TABLE tweet (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, status TEXT NOT NULL, user_id BIGINT UNSIGNED NOT NULL, created_at TIMESTAMP, updated_at TIMESTAMP)>)
Mito provides the functions connect-toplevel
and disconnect-toplevel
to establish and sever a connection to RDBMS.
connect-toplevel
takes the same arguments as dbi:connect
: typically the driver-type, the database name to connect, user name and password.
(mito:connect-toplevel :mysql :database-name "myapp" :username "fukamachi" :password "c0mon-1isp")
connect-toplevel
sets *connection*
to a new connection and returns it.
To use a connection lexically, just bind it:
(let ((mito:*connection* (dbi:connect :sqlite3 :database-name #P"/tmp/myapp.db")))
(unwind-protect (progn ...)
;; Ensure that the connection is closed.
(dbi:disconnect mito:*connection*)))
In most cases dbi:connect-cached
is a better option, since it reuses a connection for multiple threads.
(let ((mito:*connection* (dbi:connect-cached :sqlite3 :database-name #P"/tmp/myapp.db")))
(unwind-protect (progn ...)
;; Ensure that the connection is closed.
))
Use connection-database-name
to get the name of the current connection, or of one named via parameter.
As Mito's dao table class is defined as a CLOS metaclass, a table class can be defined like this:
(defclass user ()
((name :col-type (:varchar 64)
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:accessor user-email))
(:metaclass mito:dao-table-class))
deftable
's syntax is the same as that of cl:defclass
. However, the definition is a little bit redundant.
mito:deftable
is a thin macro, to allow definion of a table class with less typing.
For example, the above example can be rewritten, using deftable
as follows.
(mito:deftable user ()
((name :col-type (:varchar 64))
(email :col-type (or (:varchar 128) :null))))
It adds :metaclass mito:dao-table-class
, and adds default accessors that start with <class-name>-
by default, like defstruct
does.
The prefix for accessors can be changed with the :conc-name
class option:
(mito:deftable user ()
((name :col-type (:varchar 64))
(email :col-type (or (:varchar 128) :null)))
(:conc-name my-))
(my-name (make-instance 'user :name "fukamachi"))
;=> "fukamachi"
If :conc-name
is NIL, default accessors will NOT be defined.
In Mito, a class corresponding to a database table is defined by specifying (:metaclass mito:dao-table-class)
.
(defclass user ()
((name :col-type (:varchar 64)
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:accessor user-email))
(:metaclass mito:dao-table-class))
The above defines a Common Lisp normal class, except that it allows additional options.
(defclass {class-name} ()
({column-definition}*)
(:metaclass mito:dao-table-class)
[[class-option]])
column-definition ::= (slot-name [[column-option]])
column-option ::= {:col-type col-type} |
{:primary-key boolean} |
{:inflate inflation-function} |
{:deflate deflation-function} |
{:references {class-name | (class-name slot-name)}} |
{:ghost boolean}
col-type ::= { keyword |
(keyword . args) |
(or keyword :null) |
(or :null keyword) }
class-option ::= {:primary-key symbol*} |
{:unique-keys {symbol | (symbol*)}*} |
{:keys {symbol | (symbol*)}*} |
{:table-name table-name} |
{:auto-pk auto-pk-mixin-class-name} |
{:record-timestamps boolean} |
{:conc-name conc-name}
auto-pk-mixin-class-name ::= {:serial | :uuid}
conc-name ::= {null | string-designator}
Note: the class automatically adds some slots -- a primary key named id
if there is no primary key, created_at
and updated_at
for recording timestamps. To disable these behaviors, specify :auto-pk nil
or :record-timestamps nil
to defclass forms.
(mito.class:table-column-slots (find-class 'user))
;=> (#<MITO.DAO.COLUMN:DAO-TABLE-COLUMN-CLASS MITO.DAO.MIXIN::ID>
; #<MITO.DAO.COLUMN:DAO-TABLE-COLUMN-CLASS COMMON-LISP-USER::NAME>
; #<MITO.DAO.COLUMN:DAO-TABLE-COLUMN-CLASS COMMON-LISP-USER::EMAIL>
; #<MITO.DAO.COLUMN:DAO-TABLE-COLUMN-CLASS MITO.DAO.MIXIN::CREATED-AT>
; #<MITO.DAO.COLUMN:DAO-TABLE-COLUMN-CLASS MITO.DAO.MIXIN::UPDATED-AT>)
This class inherits mito:dao-class
implicitly.
(find-class 'user)
;=> #<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::USER>
(c2mop:class-direct-superclasses *)
;=> (#<STANDARD-CLASS MITO.DAO.TABLE:DAO-CLASS>)
This may be useful to define methods that can be applied for many or all table classes.
(mito:table-definition 'user)
;=> (#<SXQL-STATEMENT: CREATE TABLE user (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(64) NOT NULL, email VARCHAR(128), created_at TIMESTAMP, updated_at TIMESTAMP)>)
(sxql:yield *)
;=> "CREATE TABLE user (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(64) NOT NULL, email VARCHAR(128), created_at TIMESTAMP, updated_at TIMESTAMP)"
; NIL
(mapc #'mito:execute-sql (mito:table-definition 'user))
(mito:ensure-table-exists 'user)
(defvar me
(make-instance 'user :name "Eitaro Fukamachi" :email "e.arrows@gmail.com"))
;=> USER
(mito:insert-dao me)
;-> ;; INSERT INTO `user` (`name`, `email`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?) ("Eitaro Fukamachi", "e.arrows@gmail.com", "2016-02-04T19:55:16.365543Z", "2016-02-04T19:55:16.365543Z") [0 rows] | MITO.DAO:INSERT-DAO
;=> #<USER {10053C4453}>
;; Same as above
(mito:create-dao 'user :name "Eitaro Fukamachi" :email "e.arrows@gmail.com")
;; Getting the primary key value
(mito:object-id me)
;=> 1
;; Retrieving from the DB
(mito:find-dao 'user :id 1)
;-> ;; SELECT * FROM `user` WHERE (`id` = ?) LIMIT 1 (1) [1 row] | MITO.DB:RETRIEVE-BY-SQL
;=> #<USER {10077C6073}>
(mito:retrieve-dao 'user)
;=> (#<USER {10077C6073}>)
;; Updating
(setf (slot-value me 'name) "nitro_idiot")
;=> "nitro_idiot"
(mito:save-dao me)
;-> ;; UPDATE `user` SET `id` = ?, `name` = ?, `email` = ?, `created_at` = ?, `updated_at` = ? WHERE (`id` = ?) (2, "nitro_idiot", "e.arrows@gmail.com", "2016-02-04T19:56:11.408927Z", "2016-02-04T19:56:19.006020Z", 2) [0 rows] | MITO.DAO:UPDATE-DAO
;; Deleting
(mito:delete-dao me)
;-> ;; DELETE FROM `user` WHERE (`id` = ?) (1) [0 rows] | MITO.DAO:DELETE-DAO
(mito:delete-by-values 'user :id 1)
;-> ;; DELETE FROM `user` WHERE (`id` = ?) (1) [0 rows] | MITO.DAO:DELETE-DAO
;; Counting
(mito:count-dao 'user)
;-> 1
Use select-dao
to build custom queries with sxql (examples below).
To define a relationship, use :references
on the slot:
(mito:deftable user ()
((id :col-type (:varchar 36)
:primary-key t)
(name :col-type (:varchar 64))
(email :col-type (or (:varchar 128) :null))))
(mito:deftable tweet ()
((status :col-type :text)
;; This slot refers to USER class
(user-id :references (user id))))
;; The :col-type of USER-ID column is retrieved from the foreign class.
(mito:table-definition (find-class 'tweet))
;=> (#<SXQL-STATEMENT: CREATE TABLE tweet (
; id BIGSERIAL NOT NULL PRIMARY KEY,
; status TEXT NOT NULL,
; user_id VARCHAR(36) NOT NULL,
; created_at TIMESTAMPTZ,
; updated_at TIMESTAMPTZ
; )>)
You can also specify another foreign class at :col-type
to define a relationship:
(mito:deftable tweet ()
((status :col-type :text)
;; This slot refers to USER class
(user :col-type user)))
(mito:table-definition (find-class 'tweet))
;=> (#<SXQL-STATEMENT: CREATE TABLE tweet (
; id BIGSERIAL NOT NULL PRIMARY KEY,
; status TEXT NOT NULL,
; user_id VARCHAR(36) NOT NULL,
; created_at TIMESTAMP,
; updated_at TIMESTAMP
; )>)
;; You can specify :USER arg, instead of :USER-ID.
(defvar *user* (mito:create-dao 'user :name "Eitaro Fukamachi"))
(mito:create-dao 'tweet :user *user*)
(mito:find-dao 'tweet :user *user*)
The latter example allows you to create/retrieve TWEET
by a USER
object, not a USER-ID
.
Mito doesn't add foreign key constraints for referring tables, since I'm not sure it's still handful while using with ORMs.
Inflation/Deflation is a function to convert values between Mito and RDBMS.
(mito:deftable user-report ()
((title :col-type (:varchar 100))
(body :col-type :text
:initform "")
(reported-at :col-type :timestamp
:initform (local-time:now)
:inflate #'local-time:universal-to-timestamp
:deflate #'local-time:timestamp-to-universal))
(:conc-name report-))
One of the pains in the neck to use ORMs is the "N+1 query" problem.
;; BAD EXAMPLE
(use-package '(:mito :sxql))
(defvar *tweets-contain-japan*
(select-dao 'tweet
(where (:like :status "%Japan%"))))
;; Getting names of tweeted users.
(mapcar (lambda (tweet)
(user-name (tweet-user tweet)))
*tweets-contain-japan*)
This example sends a query to retrieve a user, like "SELECT * FROM user WHERE id = ?" for each iteration.
To prevent this performance issue, add includes
to the above query, which sends only a single WHERE IN query instead of N queries:
;; GOOD EXAMPLE with eager loading
(use-package '(:mito :sxql))
(defvar *tweets-contain-japan*
(select-dao 'tweet
(includes 'user)
(where (:like :status "%Japan%"))))
;-> ;; SELECT * FROM `tweet` WHERE (`status` LIKE ?) ("%Japan%") [3 row] | MITO.DB:RETRIEVE-BY-SQL
;-> ;; SELECT * FROM `user` WHERE (`id` IN (?, ?, ?)) (1, 3, 12) [3 row] | MITO.DB:RETRIEVE-BY-SQL
;=> (#<TWEET {1003513EC3}> #<TWEET {1007BABEF3}> #<TWEET {1007BB9D63}>)
;; No additional SQLs will be executed.
(tweet-user (first *))
;=> #<USER {100361E813}>
(ensure-table-exists 'user)
;-> ;; CREATE TABLE IF NOT EXISTS "user" (
; "id" BIGSERIAL NOT NULL PRIMARY KEY,
; "name" VARCHAR(64) NOT NULL,
; "email" VARCHAR(128),
; "created_at" TIMESTAMP,
; "updated_at" TIMESTAMP
; ) () [0 rows] | MITO.DAO:ENSURE-TABLE-EXISTS
;; No changes
(mito:migration-expressions 'user)
;=> NIL
(mito:deftable user ()
((name :col-type (:varchar 64))
(email :col-type (:varchar 128)))
(:unique-keys email))
(mito:migration-expressions 'user)
;=> (#<SXQL-STATEMENT: ALTER TABLE user ALTER COLUMN email TYPE character varying(128), ALTER COLUMN email SET NOT NULL>
; #<SXQL-STATEMENT: CREATE UNIQUE INDEX unique_user_email ON user (email)>)
(mito:migrate-table 'user)
;-> ;; ALTER TABLE "user" ALTER COLUMN "email" TYPE character varying(128), ALTER COLUMN "email" SET NOT NULL () [0 rows] | MITO.MIGRATION.TABLE:MIGRATE-TABLE
; ;; CREATE UNIQUE INDEX "unique_user_email" ON "user" ("email") () [0 rows] | MITO.MIGRATION.TABLE:MIGRATE-TABLE
;-> (#<SXQL-STATEMENT: ALTER TABLE user ALTER COLUMN email TYPE character varying(128), ALTER COLUMN email SET NOT NULL>
; #<SXQL-STATEMENT: CREATE UNIQUE INDEX unique_user_email ON user (email)>)
If mito:*auto-migration-mode*
is set to t
, and you are connected to a database, Mito will run migrations after
each change to model definitions.
$ ros install mito
$ mito
Usage: mito command [option...]
Commands:
generate-migrations
migrate
migration-status
Options:
-t, --type DRIVER-TYPE DBI driver type (one of "mysql", "postgres" or "sqlite3")
-d, --database DATABASE-NAME Database name to use
-u, --username USERNAME Username for RDBMS
-p, --password PASSWORD Password for RDBMS
-s, --system SYSTEM ASDF system to load (several -s's allowed)
-D, --directory DIRECTORY Directory path to keep migration SQL files (default: "/Users/nitro_idiot/Programs/lib/mito/db/")
--dry-run List SQL expressions to migrate
-f, --force Create a new empty migration file even when it's unnecessary.
mito --database postgres --username fukamachi --pasword c0mmon-l1sp
A subclass of DAO-CLASS is allowed to be inherited. This may be useful when you need classes that have similar columns:
(mito:deftable user ()
((name :col-type (:varchar 64))
(email :col-type (:varchar 128)))
(:unique-keys email))
(mito:deftable temporary-user (user)
((registered-at :col-type :timestamp)))
(mito:table-definition 'temporary-user)
;=> (#<SXQL-STATEMENT: CREATE TABLE temporary_user (
; id BIGSERIAL NOT NULL PRIMARY KEY,
; name VARCHAR(64) NOT NULL,
; email VARCHAR(128) NOT NULL,
; registered_at TIMESTAMP NOT NULL,
; created_at TIMESTAMP,
; updated_at TIMESTAMP,
; UNIQUE (email)
; )>)
If you need a 'template' for tables, not related to any specific database table, you can use DAO-TABLE-MIXIN
:
(defclass has-email ()
((email :col-type (:varchar 128)
:accessor object-email))
(:metaclass mito:dao-table-mixin)
(:unique-keys email))
;=> #<MITO.DAO.MIXIN:DAO-TABLE-MIXIN COMMON-LISP-USER::HAS-EMAIL>
(mito:deftable user (has-email)
((name :col-type (:varchar 64))))
;=> #<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::USER>
(mito:table-definition 'user)
;=> (#<SXQL-STATEMENT: CREATE TABLE user (
; id BIGSERIAL NOT NULL PRIMARY KEY,
; name VARCHAR(64) NOT NULL,
; email VARCHAR(128) NOT NULL,
; created_at TIMESTAMP,
; updated_at TIMESTAMP,
; UNIQUE (email)
; )>)
Since insert-dao
, update-dao
and delete-dao
are defined as generic functions, you can define :before
, :after
or :around
methods on those.
(defmethod mito:insert-dao :before ((object user))
(format t "~&Adding ~S...~%" (user-name object)))
(mito:create-dao 'user :name "Eitaro Fukamachi" :email "e.arrows@gmail.com")
;-> Adding "Eitaro Fukamachi"...
; ;; INSERT INTO "user" ("name", "email", "created_at", "updated_at") VALUES (?, ?, ?, ?) ("Eitaro Fukamachi", "e.arrows@gmail.com", "2016-02-16 21:13:47", "2016-02-16 21:13:47") [0 rows] | MITO.DAO:INSERT-DAO
;=> #<USER {100835FB33}>
(ql:quickload :mito)
Or, with Roswell:
ros install mito
Copyright (c) 2015 Eitaro Fukamachi (e.arrows@gmail.com)
Licensed under the LLGPL License.
Next: Modules, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The mito system | ||
• The mito-migration system | ||
• The lack-middleware-mito system | ||
• The mito-core system |
Next: The mito-migration system, Previous: Systems, Up: Systems [Contents][Index]
Eitaro Fukamachi
LLGPL
Abstraction layer for DB schema
# Mito
[](https://github.com/fukamachi/mito/actions?query=workflow%3ACI)
[](http://quickdocs.org/mito/)
Mito is yet another object relational mapper, and it aims to be a successor of [Integral](https://github.com/fukamachi/integral).
* Supports MySQL, PostgreSQL and SQLite3
* Adds ‘id‘ (serial/uuid primary key), ‘created_at‘ and ‘updated_at‘ by default like Ruby’s ActiveRecord
* Migrations
* DB schema versioning
## Warning
This software is still ALPHA quality. The APIs likely change.
This software should work fine with MySQL, PostgreSQL and SQLite3 on SBCL/Clozure CL.
## Usage
“‘common-lisp
(mito:connect-toplevel :mysql :database-name "myapp" :username "fukamachi" :password "c0mon-1isp")
;=> #<DBD.MYSQL:<DBD-MYSQL-CONNECTION> {100691BFF3}>
(mito:deftable user ()
((name :col-type (:varchar 64))
(email :col-type (or (:varchar 128) :null))))
;=> #<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::USER>
(mito:table-definition ’user)
;=> (#<SXQL-STATEMENT: CREATE TABLE user (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(64) NOT NULL, email VARCHAR(128))>)
(mito:deftable tweet ()
((status :col-type :text)
(user :col-type user)))
;=> #<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::TWEET>
(mito:table-definition ’tweet)
;=> (#<SXQL-STATEMENT: CREATE TABLE tweet (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, status TEXT NOT NULL, user_id BIGINT UNSIGNED NOT NULL, created_at TIMESTAMP, updated_at TIMESTAMP)>)
“‘
### Connecting to DB
Mito provides the functions ‘connect-toplevel‘ and ‘disconnect-toplevel‘ to establish and sever a connection to RDBMS.
‘connect-toplevel‘ takes the same arguments as ‘dbi:connect‘: typically the driver-type, the database name to connect, user name and password.
“‘common-lisp
(mito:connect-toplevel :mysql :database-name "myapp" :username "fukamachi" :password "c0mon-1isp")
“‘
‘connect-toplevel‘ sets ‘*connection*‘ to a new connection and returns it.
To use a connection lexically, just bind it:
“‘common-lisp
(let ((mito:*connection* (dbi:connect :sqlite3 :database-name #P"/tmp/myapp.db")))
(unwind-protect (progn ...)
;; Ensure that the connection is closed.
(dbi:disconnect mito:*connection*)))
“‘
In most cases ‘dbi:connect-cached‘ is a better option, since it reuses a connection for multiple threads.
“‘common-lisp
(let ((mito:*connection* (dbi:connect-cached :sqlite3 :database-name #P"/tmp/myapp.db")))
(unwind-protect (progn ...)
;; Ensure that the connection is closed.
))
“‘
Use ‘connection-database-name‘ to get the name of the current connection, or of one named via parameter.
### deftable macro
As Mito’s dao table class is defined as a CLOS metaclass, a table class can be defined like this:
“‘common-lisp
(defclass user ()
((name :col-type (:varchar 64)
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:accessor user-email))
(:metaclass mito:dao-table-class))
“‘
‘deftable‘’s syntax is the same as that of ‘cl:defclass‘. However, the definition is a little bit redundant.
‘mito:deftable‘ is a thin macro, to allow definion of a table class with less typing.
For example, the above example can be rewritten, using ‘deftable‘ as follows.
“‘common-lisp
(mito:deftable user ()
((name :col-type (:varchar 64))
(email :col-type (or (:varchar 128) :null))))
“‘
It adds ‘:metaclass mito:dao-table-class‘, and adds default accessors that start with ‘<class-name>-‘ by default, like ‘defstruct‘ does.
The prefix for accessors can be changed with the ‘:conc-name‘ class option:
“‘common-lisp
(mito:deftable user ()
((name :col-type (:varchar 64))
(email :col-type (or (:varchar 128) :null)))
(:conc-name my-))
(my-name (make-instance ’user :name "fukamachi"))
;=> "fukamachi"
“‘
If ‘:conc-name‘ is NIL, default accessors will NOT be defined.
### Class Definitions
In Mito, a class corresponding to a database table is defined by specifying ‘(:metaclass mito:dao-table-class)‘.
“‘common-lisp
(defclass user ()
((name :col-type (:varchar 64)
:accessor user-name)
(email :col-type (or (:varchar 128) :null)
:accessor user-email))
(:metaclass mito:dao-table-class))
“‘
The above defines a Common Lisp normal class, except that it allows additional options.
“‘
(defclass {class-name} ()
({column-definition}*)
(:metaclass mito:dao-table-class)
[[class-option]])
column-definition ::= (slot-name [[column-option]])
column-option ::= {:col-type col-type} |
{:primary-key boolean} |
{:inflate inflation-function} |
{:deflate deflation-function} |
{:references {class-name | (class-name slot-name)}} |
{:ghost boolean}
col-type ::= { keyword |
(keyword . args) |
(or keyword :null) |
(or :null keyword) }
class-option ::= {:primary-key symbol*} |
{:unique-keys {symbol | (symbol*)}*} |
{:keys {symbol | (symbol*)}*} |
{:table-name table-name} |
{:auto-pk auto-pk-mixin-class-name} |
{:record-timestamps boolean} |
{:conc-name conc-name}
auto-pk-mixin-class-name ::= {:serial | :uuid}
conc-name ::= {null | string-designator}
“‘
Note: the class automatically adds some slots – a primary key named ‘id‘ if there is no primary key, ‘created_at‘ and ‘updated_at‘ for recording timestamps. To disable these behaviors, specify ‘:auto-pk nil‘ or ‘:record-timestamps nil‘ to defclass forms.
“‘common-lisp
(mito.class:table-column-slots (find-class ’user))
;=> (#<MITO.DAO.COLUMN:DAO-TABLE-COLUMN-CLASS MITO.DAO.MIXIN::ID>
; #<MITO.DAO.COLUMN:DAO-TABLE-COLUMN-CLASS COMMON-LISP-USER::NAME>
; #<MITO.DAO.COLUMN:DAO-TABLE-COLUMN-CLASS COMMON-LISP-USER::EMAIL>
; #<MITO.DAO.COLUMN:DAO-TABLE-COLUMN-CLASS MITO.DAO.MIXIN::CREATED-AT>
; #<MITO.DAO.COLUMN:DAO-TABLE-COLUMN-CLASS MITO.DAO.MIXIN::UPDATED-AT>)
“‘
This class inherits ‘mito:dao-class‘ implicitly.
“‘common-lisp
(find-class ’user)
;=> #<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::USER>
(c2mop:class-direct-superclasses *)
;=> (#<STANDARD-CLASS MITO.DAO.TABLE:DAO-CLASS>)
“‘
This may be useful to define methods that can be applied for many or all table classes.
### Generating Table Definitions
“‘common-lisp
(mito:table-definition ’user)
;=> (#<SXQL-STATEMENT: CREATE TABLE user (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(64) NOT NULL, email VARCHAR(128), created_at TIMESTAMP, updated_at TIMESTAMP)>)
(sxql:yield *)
;=> "CREATE TABLE user (id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(64) NOT NULL, email VARCHAR(128), created_at TIMESTAMP, updated_at TIMESTAMP)"
; NIL
“‘
### Creating DB tables
“‘common-lisp
(mapc #’mito:execute-sql (mito:table-definition ’user))
(mito:ensure-table-exists ’user)
“‘
### CRUD
“‘common-lisp
(defvar me
(make-instance ’user :name "Eitaro Fukamachi" :email "e.arrows@gmail.com"))
;=> USER
(mito:insert-dao me)
;-> ;; INSERT INTO ‘user‘ (‘name‘, ‘email‘, ‘created_at‘, ‘updated_at‘) VALUES (?, ?, ?, ?) ("Eitaro Fukamachi", "e.arrows@gmail.com", "2016-02-04T19:55:16.365543Z", "2016-02-04T19:55:16.365543Z") [0 rows] | MITO.DAO:INSERT-DAO
;=> #<USER {10053C4453}>
;; Same as above
(mito:create-dao ’user :name "Eitaro Fukamachi" :email "e.arrows@gmail.com")
;; Getting the primary key value
(mito:object-id me)
;=> 1
;; Retrieving from the DB
(mito:find-dao ’user :id 1)
;-> ;; SELECT * FROM ‘user‘ WHERE (‘id‘ = ?) LIMIT 1 (1) [1 row] | MITO.DB:RETRIEVE-BY-SQL
;=> #<USER {10077C6073}>
(mito:retrieve-dao ’user)
;=> (#<USER {10077C6073}>)
;; Updating
(setf (slot-value me ’name) "nitro_idiot")
;=> "nitro_idiot"
(mito:save-dao me)
;-> ;; UPDATE ‘user‘ SET ‘id‘ = ?, ‘name‘ = ?, ‘email‘ = ?, ‘created_at‘ = ?, ‘updated_at‘ = ? WHERE (‘id‘ = ?) (2, "nitro_idiot", "e.arrows@gmail.com", "2016-02-04T19:56:11.408927Z", "2016-02-04T19:56:19.006020Z", 2) [0 rows] | MITO.DAO:UPDATE-DAO
;; Deleting
(mito:delete-dao me)
;-> ;; DELETE FROM ‘user‘ WHERE (‘id‘ = ?) (1) [0 rows] | MITO.DAO:DELETE-DAO
(mito:delete-by-values ’user :id 1)
;-> ;; DELETE FROM ‘user‘ WHERE (‘id‘ = ?) (1) [0 rows] | MITO.DAO:DELETE-DAO
;; Counting
(mito:count-dao ’user)
;-> 1
“‘
Use ‘select-dao‘ to build custom queries with sxql (examples below).
### Relationship
To define a relationship, use ‘:references‘ on the slot:
“‘common-lisp
(mito:deftable user ()
((id :col-type (:varchar 36)
:primary-key t)
(name :col-type (:varchar 64))
(email :col-type (or (:varchar 128) :null))))
(mito:deftable tweet ()
((status :col-type :text)
;; This slot refers to USER class
(user-id :references (user id))))
;; The :col-type of USER-ID column is retrieved from the foreign class.
(mito:table-definition (find-class ’tweet))
;=> (#<SXQL-STATEMENT: CREATE TABLE tweet (
; id BIGSERIAL NOT NULL PRIMARY KEY,
; status TEXT NOT NULL,
; user_id VARCHAR(36) NOT NULL,
; created_at TIMESTAMPTZ,
; updated_at TIMESTAMPTZ
; )>)
“‘
You can also specify another foreign class at ‘:col-type‘ to define a relationship:
“‘common-lisp
(mito:deftable tweet ()
((status :col-type :text)
;; This slot refers to USER class
(user :col-type user)))
(mito:table-definition (find-class ’tweet))
;=> (#<SXQL-STATEMENT: CREATE TABLE tweet (
; id BIGSERIAL NOT NULL PRIMARY KEY,
; status TEXT NOT NULL,
; user_id VARCHAR(36) NOT NULL,
; created_at TIMESTAMP,
; updated_at TIMESTAMP
; )>)
;; You can specify :USER arg, instead of :USER-ID.
(defvar *user* (mito:create-dao ’user :name "Eitaro Fukamachi"))
(mito:create-dao ’tweet :user *user*)
(mito:find-dao ’tweet :user *user*)
“‘
The latter example allows you to create/retrieve ‘TWEET‘ by a ‘USER‘ object, not a ‘USER-ID‘.
Mito doesn’t add foreign key constraints for referring tables, since I’m not sure it’s still handful while using with ORMs.
### Inflation/Deflation
Inflation/Deflation is a function to convert values between Mito and RDBMS.
“‘common-lisp
(mito:deftable user-report ()
((title :col-type (:varchar 100))
(body :col-type :text
:initform "")
(reported-at :col-type :timestamp
:initform (local-time:now)
:inflate #’local-time:universal-to-timestamp
:deflate #’local-time:timestamp-to-universal))
(:conc-name report-))
“‘
### Eager loading
One of the pains in the neck to use ORMs is the "N+1 query" problem.
“‘common-lisp
;; BAD EXAMPLE
(use-package ’(:mito :sxql))
(defvar *tweets-contain-japan*
(select-dao ’tweet
(where (:like :status "%Japan%"))))
;; Getting names of tweeted users.
(mapcar (lambda (tweet)
(user-name (tweet-user tweet)))
*tweets-contain-japan*)
“‘
This example sends a query to retrieve a user, like "SELECT * FROM user WHERE id = ?" for each iteration.
To prevent this performance issue, add ‘includes‘ to the above query, which sends only a single WHERE IN query instead of N queries:
“‘common-lisp
;; GOOD EXAMPLE with eager loading
(use-package ’(:mito :sxql))
(defvar *tweets-contain-japan*
(select-dao ’tweet
(includes ’user)
(where (:like :status "%Japan%"))))
;-> ;; SELECT * FROM ‘tweet‘ WHERE (‘status‘ LIKE ?) ("%Japan%") [3 row] | MITO.DB:RETRIEVE-BY-SQL
;-> ;; SELECT * FROM ‘user‘ WHERE (‘id‘ IN (?, ?, ?)) (1, 3, 12) [3 row] | MITO.DB:RETRIEVE-BY-SQL
;=> (#<TWEET {1003513EC3}> #<TWEET {1007BABEF3}> #<TWEET {1007BB9D63}>)
;; No additional SQLs will be executed.
(tweet-user (first *))
;=> #<USER {100361E813}>
“‘
### Migrations
“‘common-lisp
(ensure-table-exists ’user)
;-> ;; CREATE TABLE IF NOT EXISTS "user" (
; "id" BIGSERIAL NOT NULL PRIMARY KEY,
; "name" VARCHAR(64) NOT NULL,
; "email" VARCHAR(128),
; "created_at" TIMESTAMP,
; "updated_at" TIMESTAMP
; ) () [0 rows] | MITO.DAO:ENSURE-TABLE-EXISTS
;; No changes
(mito:migration-expressions ’user)
;=> NIL
(mito:deftable user ()
((name :col-type (:varchar 64))
(email :col-type (:varchar 128)))
(:unique-keys email))
(mito:migration-expressions ’user)
;=> (#<SXQL-STATEMENT: ALTER TABLE user ALTER COLUMN email TYPE character varying(128), ALTER COLUMN email SET NOT NULL>
; #<SXQL-STATEMENT: CREATE UNIQUE INDEX unique_user_email ON user (email)>)
(mito:migrate-table ’user)
;-> ;; ALTER TABLE "user" ALTER COLUMN "email" TYPE character varying(128), ALTER COLUMN "email" SET NOT NULL () [0 rows] | MITO.MIGRATION.TABLE:MIGRATE-TABLE
; ;; CREATE UNIQUE INDEX "unique_user_email" ON "user" ("email") () [0 rows] | MITO.MIGRATION.TABLE:MIGRATE-TABLE
;-> (#<SXQL-STATEMENT: ALTER TABLE user ALTER COLUMN email TYPE character varying(128), ALTER COLUMN email SET NOT NULL>
; #<SXQL-STATEMENT: CREATE UNIQUE INDEX unique_user_email ON user (email)>)
“‘
#### Auto migrations
If ‘mito:*auto-migration-mode*‘ is set to ‘t‘, and you are connected to a database, Mito will run migrations after
each change to model definitions.
### Schema versioning
“‘
$ ros install mito
$ mito
Usage: mito command [option...]
Commands:
generate-migrations
migrate
migration-status
Options:
-t, –type DRIVER-TYPE DBI driver type (one of "mysql", "postgres" or "sqlite3")
-d, –database DATABASE-NAME Database name to use
-u, –username USERNAME Username for RDBMS
-p, –password PASSWORD Password for RDBMS
-s, –system SYSTEM ASDF system to load (several -s’s allowed)
-D, –directory DIRECTORY Directory path to keep migration SQL files (default: "/Users/nitro_idiot/Programs/lib/mito/db/")
–dry-run List SQL expressions to migrate
-f, –force Create a new empty migration file even when it’s unnecessary.
“‘
#### Example
“‘
mito –database postgres –username fukamachi –pasword c0mmon-l1sp
“‘
### Inheritance and Mixin
A subclass of DAO-CLASS is allowed to be inherited. This may be useful when you need classes that have similar columns:
“‘common-lisp
(mito:deftable user ()
((name :col-type (:varchar 64))
(email :col-type (:varchar 128)))
(:unique-keys email))
(mito:deftable temporary-user (user)
((registered-at :col-type :timestamp)))
(mito:table-definition ’temporary-user)
;=> (#<SXQL-STATEMENT: CREATE TABLE temporary_user (
; id BIGSERIAL NOT NULL PRIMARY KEY,
; name VARCHAR(64) NOT NULL,
; email VARCHAR(128) NOT NULL,
; registered_at TIMESTAMP NOT NULL,
; created_at TIMESTAMP,
; updated_at TIMESTAMP,
; UNIQUE (email)
; )>)
“‘
If you need a ’template’ for tables, not related to any specific database table, you can use ‘DAO-TABLE-MIXIN‘:
“‘common-lisp
(defclass has-email ()
((email :col-type (:varchar 128)
:accessor object-email))
(:metaclass mito:dao-table-mixin)
(:unique-keys email))
;=> #<MITO.DAO.MIXIN:DAO-TABLE-MIXIN COMMON-LISP-USER::HAS-EMAIL>
(mito:deftable user (has-email)
((name :col-type (:varchar 64))))
;=> #<MITO.DAO.TABLE:DAO-TABLE-CLASS COMMON-LISP-USER::USER>
(mito:table-definition ’user)
;=> (#<SXQL-STATEMENT: CREATE TABLE user (
; id BIGSERIAL NOT NULL PRIMARY KEY,
; name VARCHAR(64) NOT NULL,
; email VARCHAR(128) NOT NULL,
; created_at TIMESTAMP,
; updated_at TIMESTAMP,
; UNIQUE (email)
; )>)
“‘
* [mito-attachment](https://github.com/fukamachi/mito-attachment)
* [mito-auth](https://github.com/fukamachi/mito-auth)
### Triggers
Since ‘insert-dao‘, ‘update-dao‘ and ‘delete-dao‘ are defined as generic functions, you can define ‘:before‘, ‘:after‘ or ‘:around‘ methods on those.
“‘common-lisp
(defmethod mito:insert-dao :before ((object user))
(format t "~&Adding ~S...~%" (user-name object)))
(mito:create-dao ’user :name "Eitaro Fukamachi" :email "e.arrows@gmail.com")
;-> Adding "Eitaro Fukamachi"...
; ;; INSERT INTO "user" ("name", "email", "created_at", "updated_at") VALUES (?, ?, ?, ?) ("Eitaro Fukamachi", "e.arrows@gmail.com", "2016-02-16 21:13:47", "2016-02-16 21:13:47") [0 rows] | MITO.DAO:INSERT-DAO
;=> #<USER {100835FB33}>
“‘
## Installation
“‘common-lisp
(ql:quickload :mito)
“‘
Or, with Roswell:
“‘
ros install mito
“‘
## See Also
* [CL-DBI](https://github.com/fukamachi/cl-dbi)
* [SxQL](https://github.com/fukamachi/sxql)
## Author
* Eitaro Fukamachi (e.arrows@gmail.com)
## Copyright
Copyright (c) 2015 Eitaro Fukamachi (e.arrows@gmail.com)
## License
Licensed under the LLGPL License.
0.1
mito.asd (file)
src/mito.lisp (file)
Next: The lack-middleware-mito system, Previous: The mito system, Up: Systems [Contents][Index]
Eitaro Fukamachi
LLGPL
0.1
mito-migration.asd (file)
Next: The mito-core system, Previous: The mito-migration system, Up: Systems [Contents][Index]
Eitaro Fukamachi
LLGPL
0.1
lack-middleware-mito.asd (file)
src (module)
Previous: The lack-middleware-mito system, Up: Systems [Contents][Index]
Eitaro Fukamachi
LLGPL
0.1
mito-core.asd (file)
Modules are listed depth-first from the system components tree.
Next: The lack-middleware-mito/src module, Previous: Modules, Up: Modules [Contents][Index]
mito-migration (system)
src/migration/
Next: The mito-core/core-components module, Previous: The mito-migration/migration-components module, Up: Modules [Contents][Index]
lack-middleware-mito (system)
src/
middleware.lisp (file)
Next: The mito-core/core-components/dao-components module, Previous: The lack-middleware-mito/src module, Up: Modules [Contents][Index]
mito-core (system)
src/core/
Next: The mito-core/core-components/class-components module, Previous: The mito-core/core-components module, Up: Modules [Contents][Index]
core-components (module)
src/core/dao/
Next: The mito-core/core-components/db-drivers module, Previous: The mito-core/core-components/dao-components module, Up: Modules [Contents][Index]
core-components (module)
src/core/class/
Previous: The mito-core/core-components/class-components module, Up: Modules [Contents][Index]
core-components (module)
src/core/db/
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
Next: The mito-migration․asd file, Previous: Lisp files, Up: Lisp files [Contents][Index]
Next: The lack-middleware-mito․asd file, Previous: The mito․asd file, Up: Lisp files [Contents][Index]
mito-migration.asd
mito-migration (system)
Next: The mito-core․asd file, Previous: The mito-migration․asd file, Up: Lisp files [Contents][Index]
lack-middleware-mito.asd
lack-middleware-mito (system)
Next: The mito/src/mito․lisp file, Previous: The lack-middleware-mito․asd file, Up: Lisp files [Contents][Index]
mito-core.asd
mito-core (system)
Next: The mito-migration/src/migration․lisp file, Previous: The mito-core․asd file, Up: Lisp files [Contents][Index]
Next: The mito-migration/migration-components/table․lisp file, Previous: The mito/src/mito․lisp file, Up: Lisp files [Contents][Index]
migration-components (module)
mito-migration (system)
src/migration.lisp
Next: The mito-migration/migration-components/versions․lisp file, Previous: The mito-migration/src/migration․lisp file, Up: Lisp files [Contents][Index]
sxql.lisp (file)
migration-components (module)
src/migration/table.lisp
Next: The mito-migration/migration-components/sxql․lisp file, Previous: The mito-migration/migration-components/table․lisp file, Up: Lisp files [Contents][Index]
migration-components (module)
src/migration/versions.lisp
Next: The mito-migration/migration-components/sql-parse․lisp file, Previous: The mito-migration/migration-components/versions․lisp file, Up: Lisp files [Contents][Index]
migration-components (module)
src/migration/sxql.lisp
Next: The lack-middleware-mito/src/middleware․lisp file, Previous: The mito-migration/migration-components/sxql․lisp file, Up: Lisp files [Contents][Index]
migration-components (module)
src/migration/sql-parse.lisp
parse-statements (function)
Next: The mito-core/src/core․lisp file, Previous: The mito-migration/migration-components/sql-parse․lisp file, Up: Lisp files [Contents][Index]
src (module)
src/middleware.lisp
*lack-middleware-mito* (special variable)
Next: The mito-core/core-components/dao․lisp file, Previous: The lack-middleware-mito/src/middleware․lisp file, Up: Lisp files [Contents][Index]
core-components (module)
mito-core (system)
src/core.lisp
Next: The mito-core/core-components/dao-components/table․lisp file, Previous: The mito-core/src/core․lisp file, Up: Lisp files [Contents][Index]
dao-components (module)
core-components (module)
src/core/dao.lisp
Next: The mito-core/core-components/dao-components/view․lisp file, Previous: The mito-core/core-components/dao․lisp file, Up: Lisp files [Contents][Index]
dao-components (module)
src/core/dao/table.lisp
Next: The mito-core/core-components/dao-components/mixin․lisp file, Previous: The mito-core/core-components/dao-components/table․lisp file, Up: Lisp files [Contents][Index]
column.lisp (file)
dao-components (module)
src/core/dao/view.lisp
Next: The mito-core/core-components/dao-components/column․lisp file, Previous: The mito-core/core-components/dao-components/view․lisp file, Up: Lisp files [Contents][Index]
column.lisp (file)
dao-components (module)
src/core/dao/mixin.lisp
Next: The mito-core/core-components/class․lisp file, Previous: The mito-core/core-components/dao-components/mixin․lisp file, Up: Lisp files [Contents][Index]
dao-components (module)
src/core/dao/column.lisp
Next: The mito-core/core-components/class-components/table․lisp file, Previous: The mito-core/core-components/dao-components/column․lisp file, Up: Lisp files [Contents][Index]
class-components (module)
core-components (module)
src/core/class.lisp
Next: The mito-core/core-components/class-components/column․lisp file, Previous: The mito-core/core-components/class․lisp file, Up: Lisp files [Contents][Index]
column.lisp (file)
class-components (module)
src/core/class/table.lisp
Next: The mito-core/core-components/connection․lisp file, Previous: The mito-core/core-components/class-components/table․lisp file, Up: Lisp files [Contents][Index]
class-components (module)
src/core/class/column.lisp
Next: The mito-core/core-components/type․lisp file, Previous: The mito-core/core-components/class-components/column․lisp file, Up: Lisp files [Contents][Index]
error.lisp (file)
core-components (module)
src/core/connection.lisp
Next: The mito-core/core-components/db․lisp file, Previous: The mito-core/core-components/connection․lisp file, Up: Lisp files [Contents][Index]
db.lisp (file)
core-components (module)
src/core/type.lisp
Next: The mito-core/core-components/db-drivers/mysql․lisp file, Previous: The mito-core/core-components/type․lisp file, Up: Lisp files [Contents][Index]
core-components (module)
src/core/db.lisp
Next: The mito-core/core-components/db-drivers/postgres․lisp file, Previous: The mito-core/core-components/db․lisp file, Up: Lisp files [Contents][Index]
db-drivers (module)
src/core/db/mysql.lisp
ensure-string (function)
Next: The mito-core/core-components/db-drivers/sqlite3․lisp file, Previous: The mito-core/core-components/db-drivers/mysql․lisp file, Up: Lisp files [Contents][Index]
db-drivers (module)
src/core/db/postgres.lisp
get-serial-keys (function)
Next: The mito-core/core-components/logger․lisp file, Previous: The mito-core/core-components/db-drivers/postgres․lisp file, Up: Lisp files [Contents][Index]
db-drivers (module)
src/core/db/sqlite3.lisp
Next: The mito-core/core-components/error․lisp file, Previous: The mito-core/core-components/db-drivers/sqlite3․lisp file, Up: Lisp files [Contents][Index]
core-components (module)
src/core/logger.lisp
Next: The mito-core/core-components/util․lisp file, Previous: The mito-core/core-components/logger․lisp file, Up: Lisp files [Contents][Index]
core-components (module)
src/core/error.lisp
Previous: The mito-core/core-components/error․lisp file, Up: Lisp files [Contents][Index]
core-components (module)
src/core/util.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
Next: The mito package, Previous: Packages, Up: Packages [Contents][Index]
mito.asd
Next: The mito-migration-asd package, Previous: The mito-asd package, Up: Packages [Contents][Index]
src/mito.lisp (file)
common-lisp
Next: The mito․migration package, Previous: The mito package, Up: Packages [Contents][Index]
mito-migration.asd
Next: The mito․migration․table package, Previous: The mito-migration-asd package, Up: Packages [Contents][Index]
src/migration.lisp (file)
common-lisp
Next: The mito․migration․versions package, Previous: The mito․migration package, Up: Packages [Contents][Index]
table.lisp (file)
Next: The mito․migration․sxql package, Previous: The mito․migration․table package, Up: Packages [Contents][Index]
versions.lisp (file)
Next: The mito․migration․sql-parse package, Previous: The mito․migration․versions package, Up: Packages [Contents][Index]
Extansions of SxQL for Mito.Migration
sxql.lisp (file)
common-lisp
Next: The mito․middleware package, Previous: The mito․migration․sxql package, Up: Packages [Contents][Index]
sql-parse.lisp (file)
parse-statements (function)
Next: The mito․core package, Previous: The mito․migration․sql-parse package, Up: Packages [Contents][Index]
middleware.lisp (file)
lack.middleware.mito
common-lisp
*lack-middleware-mito* (special variable)
Next: The mito․dao package, Previous: The mito․middleware package, Up: Packages [Contents][Index]
src/core.lisp (file)
common-lisp
Next: The mito․dao․table package, Previous: The mito․core package, Up: Packages [Contents][Index]
dao.lisp (file)
Next: The mito․dao․view package, Previous: The mito․dao package, Up: Packages [Contents][Index]
table.lisp (file)
Next: The mito․dao․mixin package, Previous: The mito․dao․table package, Up: Packages [Contents][Index]
view.lisp (file)
common-lisp
Next: The mito․dao․column package, Previous: The mito․dao․view package, Up: Packages [Contents][Index]
mixin.lisp (file)
Next: The mito․class package, Previous: The mito․dao․mixin package, Up: Packages [Contents][Index]
column.lisp (file)
Next: The mito․class․table package, Previous: The mito․dao․column package, Up: Packages [Contents][Index]
class.lisp (file)
Next: The mito․class․column package, Previous: The mito․class package, Up: Packages [Contents][Index]
table.lisp (file)
Next: The mito․connection package, Previous: The mito․class․table package, Up: Packages [Contents][Index]
column.lisp (file)
Next: The mito․type package, Previous: The mito․class․column package, Up: Packages [Contents][Index]
connection.lisp (file)
Next: The mito․db package, Previous: The mito․connection package, Up: Packages [Contents][Index]
type.lisp (file)
common-lisp
Next: The mito․db․mysql package, Previous: The mito․type package, Up: Packages [Contents][Index]
db.lisp (file)
common-lisp
Next: The mito․db․postgres package, Previous: The mito․db package, Up: Packages [Contents][Index]
mysql.lisp (file)
ensure-string (function)
Next: The mito․db․sqlite3 package, Previous: The mito․db․mysql package, Up: Packages [Contents][Index]
postgres.lisp (file)
get-serial-keys (function)
Next: The mito․logger package, Previous: The mito․db․postgres package, Up: Packages [Contents][Index]
sqlite3.lisp (file)
Next: The mito․error package, Previous: The mito․db․sqlite3 package, Up: Packages [Contents][Index]
logger.lisp (file)
common-lisp
Next: The mito․util package, Previous: The mito․logger package, Up: Packages [Contents][Index]
error.lisp (file)
common-lisp
Previous: The mito․error package, Up: Packages [Contents][Index]
util.lisp (file)
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported special variables | ||
• Exported macros | ||
• Exported functions | ||
• Exported generic functions | ||
• Exported conditions | ||
• Exported classes |
Next: Exported macros, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
table.lisp (file)
connection.lisp (file)
middleware.lisp (file)
logger.lisp (file)
Stream to output sql generated during migrations.
logger.lisp (file)
logger.lisp (file)
EXPERIMENTAL FEATURE: If this is T, Mito uses DBI:PREPARE-CACHED
to retrieve/execute SQLs instead of DBI:PREPARE. The default value is NIL.
Note that DBI:PREPARE-CACHED is added CL-DBI v0.9.5.
Next: Exported functions, Previous: Exported special variables, Up: Exported definitions [Contents][Index]
connection.lisp (file)
logger.lisp (file)
logger.lisp (file)
Next: Exported generic functions, Previous: Exported macros, Up: Exported definitions [Contents][Index]
versions.lisp (file)
connection.lisp (file)
mysql.lisp (file)
postgres.lisp (file)
sqlite3.lisp (file)
connection.lisp (file)
connection.lisp (file)
Return the name of the current connection, or the one given as argument.
connection.lisp (file)
connection.lisp (file)
versions.lisp (file)
table.lisp (file)
connection.lisp (file)
connection.lisp (file)
Same as DBI:EXECUTE except will recreate a prepared statement when getting DBI:DBI-DATABASE-ERROR.
table.lisp (file)
table.lisp (file)
table.lisp (file)
versions.lisp (file)
mysql.lisp (file)
postgres.lisp (file)
sqlite3.lisp (file)
Compute differences two lists.
Note this can be applied for a list of string-designators.
mixin.lisp (file)
versions.lisp (file)
table.lisp (file)
versions.lisp (file)
logger.lisp (file)
sql-parse.lisp (file)
table.lisp (file)
table.lisp (file)
mysql.lisp (file)
postgres.lisp (file)
sqlite3.lisp (file)
mysql.lisp (file)
postgres.lisp (file)
versions.lisp (file)
Next: Exported conditions, Previous: Exported functions, Up: Exported definitions [Contents][Index]
dao.lisp (file)
class.lisp (file)
automatically generated reader method
mixin.lisp (file)
automatically generated writer method
mixin.lisp (file)
column.lisp (file)
column.lisp (file)
automatically generated reader method
view.lisp (file)
table.lisp (file)
column.lisp (file)
Option to specify slots as ghost slots. Ghost slots do not depend on a database.
column.lisp (file)
column.lisp (file)
table.lisp (file)
automatically generated reader method
mixin.lisp (file)
automatically generated writer method
mixin.lisp (file)
mixin.lisp (file)
automatically generated reader method
mixin.lisp (file)
automatically generated writer method
mixin.lisp (file)
mixin.lisp (file)
automatically generated reader method
column.lisp (file)
automatically generated writer method
column.lisp (file)
column.lisp (file)
Similar to table-column-info except the return value is for sxql:make-create-table.
column.lisp (file)
column.lisp (file)
column.lisp (file)
automatically generated reader method
column.lisp (file)
column.lisp (file)
class.lisp (file)
column.lisp (file)
view.lisp (file)
table.lisp (file)
table.lisp (file)
table.lisp (file)
table.lisp (file)
table.lisp (file)
Next: Exported classes, Previous: Exported generic functions, Up: Exported definitions [Contents][Index]
error.lisp (file)
invalid-definition (condition)
:slot
error.lisp (file)
mito-error (condition)
error.lisp (file)
mito-error (condition)
col-type-required (condition)
error.lisp (file)
error (condition)
error.lisp (file)
mito-error (condition)
:table
Previous: Exported conditions, Up: Exported definitions [Contents][Index]
mixin.lisp (file)
standard-object (class)
boolean
dao-synced (generic function)
(setf dao-synced) (generic function)
table.lisp (file)
dao-table-mixin (class)
:auto-pk
(quote (:serial))
:record-timestamps
(quote (t))
column.lisp (file)
table-column-class (class)
(or function null)
:inflate
(or function null)
:deflate
mixin.lisp (file)
table-class (class)
dao-table-class (class)
view.lisp (file)
table-class (class)
:as
(error ":as query is required for dao-table-view")
dao-table-view-as-query (generic function)
mixin.lisp (file)
standard-object (class)
:created-at
object-created-at (generic function)
(setf object-created-at) (generic function)
:updated-at
object-updated-at (generic function)
(setf object-updated-at) (generic function)
mixin.lisp (file)
standard-object (class)
:id
%object-id (generic function)
(setf %object-id) (generic function)
table.lisp (file)
standard-class (class)
:primary-key
:unique-keys
:keys
:table-name
column.lisp (file)
standard-direct-slot-definition (class)
dao-table-column-class (class)
(or symbol cons null)
:col-type
%table-column-type (generic function)
(setf %table-column-type) (generic function)
mito.class.column::references
:references
table-column-references (generic function)
boolean
:primary-key
primary-key-p (generic function)
(setf primary-key-p) (generic function)
Option to specify slots as ghost slots. Ghost slots do not depend on a database.
boolean
:ghost
ghost-slot-p (generic function)
(setf ghost-slot-p) (generic function)
mixin.lisp (file)
standard-object (class)
:id
(mito.dao.mixin::generate-uuid)
%object-uuid (generic function)
(setf %object-uuid) (generic function)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables | ||
• Internal functions | ||
• Internal generic functions | ||
• Internal structures | ||
• Internal types |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
column.lisp (file)
column.lisp (file)
column.lisp (file)
column.lisp (file)
Next: Internal generic functions, Previous: Internal special variables, Up: Internal definitions [Contents][Index]
versions.lisp (file)
table.lisp (file)
mixin.lisp (file)
versions.lisp (file)
table.lisp (file)
sxql.lisp (file)
view.lisp (file)
sxql.lisp (file)
sxql.lisp (file)
sxql.lisp (file)
sxql.lisp (file)
sxql.lisp (file)
view.lisp (file)
view.lisp (file)
view.lisp (file)
view.lisp (file)
view.lisp (file)
sxql.lisp (file)
sxql.lisp (file)
sxql.lisp (file)
sxql.lisp (file)
mysql.lisp (file)
Expand relational columns if the operator is :=, :!= , :in or :not-in.
table.lisp (file)
mixin.lisp (file)
versions.lisp (file)
logger.lisp (file)
postgres.lisp (file)
table.lisp (file)
table.lisp (file)
table.lisp (file)
versions.lisp (file)
sxql.lisp (file)
view.lisp (file)
sxql.lisp (file)
mixin.lisp (file)
sxql.lisp (file)
table.lisp (file)
table.lisp (file)
table.lisp (file)
versions.lisp (file)
versions.lisp (file)
column.lisp (file)
table.lisp (file)
versions.lisp (file)
sxql.lisp (file)
sxql.lisp (file)
sxql.lisp (file)
sqlite3.lisp (file)
sqlite3.lisp (file)
logger.lisp (file)
Next: Internal structures, Previous: Internal functions, Up: Internal definitions [Contents][Index]
automatically generated reader method
mixin.lisp (file)
automatically generated writer method
mixin.lisp (file)
automatically generated reader method
mixin.lisp (file)
automatically generated writer method
mixin.lisp (file)
automatically generated reader method
column.lisp (file)
automatically generated writer method
column.lisp (file)
Next: Internal types, Previous: Internal generic functions, Up: Internal definitions [Contents][Index]
sxql.lisp (file)
sql-statement (structure)
yield (method)
string
"create sequence"
create-sequence-name (function)
(setf create-sequence-name) (function)
create-sequence-sequence-name (function)
(setf create-sequence-sequence-name) (function)
view.lisp (file)
sql-statement (structure)
yield (method)
string
"create view"
create-view-name (function)
(setf create-view-name) (function)
create-view-view-name (function)
(setf create-view-view-name) (function)
create-view-or-replace (function)
(setf create-view-or-replace) (function)
create-view-as (function)
(setf create-view-as) (function)
sxql.lisp (file)
sql-statement (structure)
yield (method)
string
"drop sequence"
drop-sequence-name (function)
(setf drop-sequence-name) (function)
drop-sequence-sequence-name (function)
(setf drop-sequence-sequence-name) (function)
drop-sequence-if-exists (function)
(setf drop-sequence-if-exists) (function)
sxql.lisp (file)
expression-clause (structure)
string
"set default"
set-default-name (function)
(setf set-default-name) (function)
Previous: Internal structures, Up: Internal definitions [Contents][Index]
column.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F L M |
---|
Jump to: | F L M |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | %
(
A C D E F G I L M O P R S T U W |
---|
Jump to: | %
(
A C D E F G I L M O P R S T U W |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
A C D G I K N O P R S T U V |
---|
Jump to: | *
A C D G I K N O P R S T U V |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C D I L M N P R S T U |
---|
Jump to: | C D I L M N P R S T U |
---|