I am trying to use the eieio-persistent class to make persistent objects. My goal is to store many objects in a file.
I am not sure how to achieve this though. If I use this code, I do get a persistent object saved in test.db, but (perhaps predictably) the second save overwrites the first one.
(defclass animal (eieio-persistent)
((type :initarg :type)
(file :initform "/Users/jkitchin/Dropbox/org-mode/test.db")))
(let ((a1 (animal :type 'mammal)))
(eieio-persistent-save a1))
(let ((a1 (animal :type 'rodent)))
(eieio-persistent-save a1))
Is there a way to save a list of these "animals" using the eieio framework? I would prefer not to create individual files for each object (I am anticipating thousands of objects later that need to be read in). Ideally, there would be another class that had a list of these animal objects in a records field.
Something like this is close
(defclass animal-db (eieio-named eieio-persistent)
((id :initarg :id)
(file :initform "/Users/jkitchin/Dropbox/org-mode/test.db")
(records :initarg :records :type listp))
"Base db for animal class")
but the list in the records doesn't appear to be actual objects, when I read the code back in, but code that needs to be eval'd to get the object.
Any ideas?