Stuff.
parent
1e6814f4db
commit
9a687a35cb
|
@ -1,4 +1,21 @@
|
|||
.so macros.roff
|
||||
.de TREE1
|
||||
.QP
|
||||
.KS
|
||||
.ft CW
|
||||
.b1
|
||||
.nf
|
||||
..
|
||||
.de TREE2
|
||||
.ft
|
||||
.fi
|
||||
.b2
|
||||
.KE
|
||||
.QE
|
||||
..
|
||||
.
|
||||
. \" The document starts here.
|
||||
.
|
||||
.TITLE Document Oriented DataBase (DODB)
|
||||
.AUTHOR Philippe P.
|
||||
.ABSTRACT1
|
||||
|
@ -156,15 +173,13 @@ Let's create a DODB database for our cars.
|
|||
db = DODB::DataBase(Car).new "path/to/db-cars"
|
||||
|
||||
# Adding an element to the db
|
||||
db << Car.new "Corvet GT", "red", ["elegant", "fast"]
|
||||
db << Car.new "Corvet", "red", ["elegant", "fast"]
|
||||
|
||||
# Reaching all objects in the db
|
||||
db.each do |car|
|
||||
pp! car
|
||||
end
|
||||
.SOURCE
|
||||
|
||||
.SS Storing data
|
||||
When a value is added, it is serialized\*[*] and written in a dedicated file.
|
||||
.FOOTNOTE1
|
||||
Serialization is currently in JSON.
|
||||
|
@ -172,32 +187,30 @@ CBOR is a work-in-progress.
|
|||
Nothing binds DODB to a particular format.
|
||||
.FOOTNOTE2
|
||||
The key of the hash is a number, auto-incremented, used as the name of the stored file.
|
||||
The following example shows the content of the file system after adding three values.
|
||||
.de TREE1
|
||||
.QP
|
||||
.KS
|
||||
.ft CW
|
||||
.b1
|
||||
.nf
|
||||
..
|
||||
.de TREE2
|
||||
.ft
|
||||
.fi
|
||||
.b2
|
||||
.KE
|
||||
.QE
|
||||
..
|
||||
The following example shows the content of the file system after adding the first car.
|
||||
.TREE1
|
||||
$ tree storage/
|
||||
storage
|
||||
`-- data
|
||||
+-- 0000000000
|
||||
+-- 0000000001
|
||||
`-- 0000000002
|
||||
$ tree db-cars/
|
||||
db-cars/
|
||||
|-- data
|
||||
| `-- 0000000000 <- the first car in the database
|
||||
`-- last-index
|
||||
.TREE2
|
||||
In this example, the directory
|
||||
.I storage/data
|
||||
contains all three serialized values, with a formated number as their file name.
|
||||
.I db-cars/data
|
||||
contains the serialized value, with a formated number as file name.
|
||||
The file "0000000000" contains the following:
|
||||
.QP
|
||||
.SOURCE JSON ps=10
|
||||
{
|
||||
"name": "Corvet",
|
||||
"color": "red",
|
||||
"keywords": [
|
||||
"elegant",
|
||||
"fast"
|
||||
]
|
||||
}
|
||||
.SOURCE
|
||||
.QE
|
||||
.SS Indexes
|
||||
Database entries can be
|
||||
.I indexed
|
||||
|
|
Loading…
Reference in New Issue