Last active
December 31, 2022 19:01
-
-
Save rainthree/87d0271a98bf1539a728f830f35cae1c to your computer and use it in GitHub Desktop.
stassats-storage simple working example https://github.com/stassats/storage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; stassats-storage simple working example https://www.cliki.net/stassats-storage | |
(uiop:define-package #:tmp | |
(:use :cl) | |
(:local-nicknames (:db :storage))) | |
(in-package #:tmp) | |
(defparameter *storage* | |
(make-instance 'db:storage :file "f.db")) | |
(defclass my-storable-class (db:storable-class) | |
((db::storage :initform *storage*))) | |
(defclass role () | |
((|name| :initarg :name :type simple-string :storep nil) | |
(|bitmask| :initarg :bitmask :type fixnum :storep t)) | |
(:metaclass my-storable-class) | |
#+c(:storage #.*storage*)) | |
(when (null (db::objects-of-class (find-class 'role))) | |
(db:load-data *storage*)) | |
#+c(setf (find-class 'role) nil) | |
(when (null (db::objects-of-class (find-class 'role))) | |
(db:add 'role :name "aaa" :bitmask 4)) | |
(defparameter *objs* | |
(db::objects-of-class (find-class 'role))) | |
(db::slots-to-store (find-class 'role)) | |
(db::id (first *objs*)) | |
#+c(defparameter *o (make-instance 'role :name "aaa" :bitmask 4)) | |
(db:save-data *storage*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment