diff --git a/src/dodb.cl b/src/dodb.cl old mode 100644 new mode 100755 index 738b5ef..4d1c134 --- a/src/dodb.cl +++ b/src/dodb.cl @@ -1,3 +1,7 @@ +#!/usr/local/bin/clisp + +(load "./util.cl") + (defpackage :dodb (:use :common-lisp :util) ; TODO @@ -18,8 +22,32 @@ ; car = Car.new "Mustang", "red", [] of String ; cars_by_name.update_or_create car.name, car + +; (defstruct index name func) +; index "name" (lambda (x) (car-name x)) + +; index = 1-1 +; partition = 1-n +; String Path [String] [String] +(defstruct db struct-name path (indexes ()) (partitions ())) + +(defun db/new (struct-name path) + (ensure-directories-exist path) + (make-db :struct-name struct-name :path path)) + +; example: db-path/by_name/ +(defun db/new-index (database attribute-name) + (ensure-directories-exist + (concatenate 'string (db-path database) "/by_" attribute-name "/")) + ) + +; test structure +(defstruct vehicle name color) + ; TODO -; (setf cars (db/new :structure car :directory "./storage")) +(setf cars (db/new "vehicle" "./storage/cars/")) +; (format t "~&~S~&" cars) +(db/new-index cars "name") ; (setf cars_by_name (db/new-index cars "name")) ; (db/get-by-index cars "name" "foo")) -; (setf cars_by_name (db/new-index cars "name" (optional: (lambda (x) (car-name x))))) +; (setf cars_by_name (db/new-index cars "name" (optional: (lambda (x) (vehicle-name x)))))