unimportant

This commit is contained in:
uleelx 2015-04-06 21:57:17 +08:00
parent aa924bf01f
commit 73a5bfa5ba
1 changed files with 29 additions and 24 deletions

View File

@ -18,34 +18,39 @@ Then write this in any Lua file where you want to use it:
local flatdb = require 'flatdb'
```
1. Bind a directory as a database
```lua
local db = flatdb('./db')
```
1. Bind a directory as a database
2. Open or create a book
```lua
if not db.book then
db.book = {}
end
```
```lua
local db = flatdb('./db')
```
3. Store key-value items
```lua
db.book.key = 'value'
-- equivalent to db.book['key'] = 'value'
```
2. Open or create a book
4. Retrieve items
```lua
print(db.book.key) -- prints 'value'
```
```lua
if not db.book then
db.book = {}
end
```
5. Save to file
```lua
db:save()
-- 'book' will be saved to './db/book'
```
3. Store key-value items
```lua
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).