forked from mtcontrib/colddb
unimportant
This commit is contained in:
parent
aa924bf01f
commit
73a5bfa5ba
53
README.md
53
README.md
@ -18,34 +18,39 @@ Then write this in any Lua file where you want to use it:
|
|||||||
local flatdb = require 'flatdb'
|
local flatdb = require 'flatdb'
|
||||||
```
|
```
|
||||||
|
|
||||||
1. Bind a directory as a database
|
1. Bind a directory as a database
|
||||||
```lua
|
|
||||||
local db = flatdb('./db')
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Open or create a book
|
```lua
|
||||||
```lua
|
local db = flatdb('./db')
|
||||||
if not db.book then
|
```
|
||||||
db.book = {}
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Store key-value items
|
2. Open or create a book
|
||||||
```lua
|
|
||||||
db.book.key = 'value'
|
|
||||||
-- equivalent to db.book['key'] = 'value'
|
|
||||||
```
|
|
||||||
|
|
||||||
4. Retrieve items
|
```lua
|
||||||
```lua
|
if not db.book then
|
||||||
print(db.book.key) -- prints 'value'
|
db.book = {}
|
||||||
```
|
end
|
||||||
|
```
|
||||||
|
|
||||||
5. Save to file
|
3. Store key-value items
|
||||||
```lua
|
|
||||||
db:save()
|
```lua
|
||||||
-- 'book' will be saved to './db/book'
|
db.book.key = 'value'
|
||||||
```
|
-- equivalent to db.book['key'] = 'value'
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Retrieve items
|
||||||
|
|
||||||
|
```lua
|
||||||
|
print(db.book.key) -- prints 'value'
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Save to file
|
||||||
|
|
||||||
|
```lua
|
||||||
|
db:save()
|
||||||
|
-- 'book' will be saved to './db/book'
|
||||||
|
```
|
||||||
|
|
||||||
More usage can be found in the *cli.lua*(a Redis-like command line interface example using FlatDB).
|
More usage can be found in the *cli.lua*(a Redis-like command line interface example using FlatDB).
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user