The lambdalite Reference Manual

This is the lambdalite Reference Manual, version 1.0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed May 15 05:42:57 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 lambdalite

A functional, relational Lisp database

Author

Wukix Inc <>

License

MIT

Long Description

A functional, relational database in about 250 lines of Common Lisp

Version

1.0.1

Dependencies
  • wu-sugar (system).
  • bordeaux-threads (system).
Source

lambdalite.asd.

Child Component

lambdalite.lisp (file).


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 lambdalite/lambdalite.asd

Source

lambdalite.asd.

Parent Component

lambdalite (system).

ASDF Systems

lambdalite.

Packages

lambdalite-asd.


3.1.2 lambdalite/lambdalite.lisp

Source

lambdalite.asd.

Parent Component

lambdalite (system).

Packages

lambdalite.

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 lambdalite-asd

Source

lambdalite.asd.

Use List
  • asdf/interface.
  • common-lisp.

4.2 lambdalite

Source

lambdalite.lisp.

Use List
  • common-lisp.
  • wu-sugar.
Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Macros

Macro: defattributes (&body body)

Defines getter functions and validation functions for row attributes. Example:
(defattributes
:/item-id
:/title (lambda (x) (<= 1 (length x) 200)))
This would create the getter functions :/item-id and :/title, plus the validation function valid-title-p.

Package

lambdalite.

Source

lambdalite.lisp.

Macro: keyset (&rest key/value-pairs)

An ’update function’ for use in UPDATE. Example: (update :things (where foo) (keyset :/bar 1 :/baz 2))

Package

lambdalite.

Source

lambdalite.lisp.

Macro: where (expression)
Package

lambdalite.

Source

lambdalite.lisp.

Macro: where-on (row-binding expression)

Like WHERE, except giving direct access to the row, bound to ROW-BINDING. Unlike WHERE, EXPRESSION runs unmodified. Example: (select :users (where-on u (equal (:/age u) 30)))

Package

lambdalite.

Source

lambdalite.lisp.

Macro: with-tx (&body body)

Execute a transaction as follows:
1. Every command that writes executes against a temporary table.
2. Back up the real target tables on disk.
3. Swap the target tables with the temporary ones in memory and persist.
4. If 3 does not complete, reverse the original swaps with the temporary tables and restore the backups as primary. 5. Delete backup files and temporary tables.

Package

lambdalite.

Source

lambdalite.lisp.


5.1.2 Ordinary functions

Function: del (name where-predicate)

Usage: (del :foo (where ...))

Package

lambdalite.

Source

lambdalite.lisp.

Function: insert (name &rest rows)

Example: (insert :users (:/user-id 1 :/name "Bob") (:/user-id 2 :/name "Alice"))

Package

lambdalite.

Source

lambdalite.lisp.

Function: list-tables ()

Returns a list of table names (as keywords).

Package

lambdalite.

Source

lambdalite.lisp.

Function: load-db (&key path)

Loads data files if they exist at PATH, or initializes an empty setup if not. Call once at startup.

Package

lambdalite.

Source

lambdalite.lisp.

Function: select (name &optional where-predicate)

Example: (select :users (where (search "Bob" :/name)))

Package

lambdalite.

Source

lambdalite.lisp.

Function: select1 (name &optional where-predicate)

Like SELECT, but returns the first row found.

Package

lambdalite.

Source

lambdalite.lisp.

Function: update (name where-predicate update-function)

Example: (update :things (where (evenp :/foo)) (keyset :/bar 1 :/baz 2))

Package

lambdalite.

Source

lambdalite.lisp.


5.2 Internals


5.2.1 Special variables

Special Variable: *db*
Package

lambdalite.

Source

lambdalite.lisp.

Special Variable: *db-path*
Package

lambdalite.

Source

lambdalite.lisp.

Special Variable: *tx*
Package

lambdalite.

Source

lambdalite.lisp.

Special Variable: *tx-lock*
Package

lambdalite.

Source

lambdalite.lisp.

Special Variable: *tx-modified-list*
Package

lambdalite.

Source

lambdalite.lisp.


5.2.2 Macros

Macro: with-lock (&body body)
Package

lambdalite.

Source

lambdalite.lisp.


5.2.3 Ordinary functions

Function: clone-temporary (name)
Package

lambdalite.

Source

lambdalite.lisp.

Function: make-filename (name)
Package

lambdalite.

Source

lambdalite.lisp.

Function: persist (name &optional filename)
Package

lambdalite.

Source

lambdalite.lisp.


Appendix A Indexes


A.1 Concepts