Skip to content

Tass0sm/emacs-orm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ORM

(deftable person ()
          ((name :initarg :name
      	         :primary-key t
      	         :not-null t)
           (age  :initarg :age))
          :table people
          :documentation
          "Person class with correspondence to a table named people")

Summary

Provides a way to define EIEIO classes which correspond to tables in a database. Instances of the class correspond to records in a table. Slots of the class correspond to columns in the table.

Features

Define classes mapped to tables.

(deftable name mixins column-specs &rest options-and-doc)
(orm-table-p table)

Create and Drop Tables.

(orm-create (table (subclass orm-table)))
(orm-drop (table (subclass orm-table)))

Create new rows in the table.

(orm-insert (obj orm-table))
(orm-insert-or-update (obj orm-table))

Check for and read rows from the table.

(orm-present-p (obj orm-table))
(orm-first (table (subclass orm-table)))
(orm-all (table (subclass orm-table)))
(orm-find (table (subclass orm-table)) id)

Update rows in the table.

(orm-update (obj orm-table))

Delete rows from the table

(orm-delete (obj orm-table))

Associations

Define belongs-to, has-one, has-many, and has-and-belongs-to-many associations between table-mapped objects.

(defassoc table1 type table2 &rest options)

The above operations when applied to objects with associations will respect those associations and keep the database up-to-date with the association data included in the objects. There are also a separate set of operations specifically for dealing with associations.

Get an association by name.

(orm-assoc-get (table (subclass orm-table)) association-name)
(orm-assoc-get (obj orm-table) association-name)

Create new rows in the association.

(orm-assoc-insert (obj1 orm-table) association-name (obj2 orm-table))

Check for and read rows from the association.

(orm-assoc-present-p (obj1 orm-table) association-name (obj2 orm-table))
(orm-assoc-first (obj orm-table) association-name)
(orm-assoc-all (obj orm-table) association-name)
(orm-assoc-find (obj orm-table) association-name)

Delete rows from the association.

(orm-assoc-delete (obj1 orm-table) association-name (obj2 orm-table))

Objects associated with other objects are also considered during deletion.

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •