From fb84d81075a860d9c4a37f65f830e0fd07281fb0 Mon Sep 17 00:00:00 2001 From: kimory Date: Tue, 18 Oct 2022 22:44:37 +0200 Subject: [PATCH] Adapt scenario to new API. --- src/scenario.cl | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/scenario.cl b/src/scenario.cl index b479ea9..07e9a96 100644 --- a/src/scenario.cl +++ b/src/scenario.cl @@ -1,31 +1,25 @@ (in-package :dodb) -; -; TEST SCENARIO -; +(defstruct vehicle name color (nb-of-lights 4)) -(defstruct vehicle name color (nb_of_lights 4)) - -;(defparameter cars (db/new "vehicle" "./storage/cars/")) ; to launch the tests in RAM -(defparameter cars (db/new "vehicle" "/tmp/storage/cars/")) +(defparameter cars (db/new "/tmp/storage/cars/")) (db/add cars (make-vehicle :name "Corvet" :color "Red")) (db/add cars (make-vehicle :name "Ferrari" :color "Red")) (db/add cars (make-vehicle :name "Deudeuch" :color "Beige")) (db/add cars (make-vehicle :name "BMW" :color "Blue")) -(db/add cars (make-vehicle :name "Suzuki Wagon" :color "Blue" :nb_of_lights 6)) - -(db/new-index cars "name") -(db/new-partition cars "color") -(db/new-partition cars "nb_of_lights") +(db/add cars (make-vehicle :name "Suzuki Wagon" :color "Blue" :nb-of-lights 6)) +(db/new-index cars "name" #'vehicle-name) +(db/new-partition cars "color" #'vehicle-color) +(db/new-partition cars "nb-of-lights" #'vehicle-nb-of-lights) (format t "~&~S~&" cars) (format t "db/get-by-index ~S~&" (db/get-by-index cars "name" "Corvet")) -(format t "db/get-by-partition red cars:~&") +(format t "db/get-by-partition red cars:~&") (loop for car in (db/get-by-partition cars "color" "Red") do (format t "- ~S~&" car))