boltdb/bolt bindings for Lua.
package main
import (
"ofunc/lmodbolt"
"ofunc/lua/util"
)
func main() {
l := util.NewState()
l.Preload("bolt", lmodbolt.Open)
util.Run(l, "main.lua")
}
local bolt = require 'bolt'
local db = bolt.open('test.db')
db:update(function(tx)
local demo = tx:bucket('demo')
demo:set('foo', {
id = 123;
name = 'test';
valid = true;
})
local foo = tx:bucket('demo'):get('foo')
print(foo.id, foo.name, foo.valid)
end)
db:close()
Creates and opens a database at the given path
.
If the file does not exist then it will be created automatically.
Releases all database resources. All transactions must be closed before closing the database.
Executes the function f
within the context of a managed read-only transaction.
Any error in function f
is returned from the view
method.
Executes the function f
within the context of a read-write managed transaction.
If no error in the function f
then the transaction is committed.
Otherwise the entire transaction is rolled back.
Any error in function f
is returned from the update
method.
Writes the entire database to a writer.
Retrieves a nested bucket by key
.
If the bucket does not exist then it will be created automatically.
c
is a tx or a bucket.
Returns an iterator that can traverse over all key/bucket pairs (start from key
) in a bucket in sorted order.
c
is a tx or a bucket.
Deletes a bucket at the given key
.
c
is a tx or a bucket.
Retrieves the value for a key
in the bucket.
Sets the value
for the key
in the bucket.
If the key
exist then it's previous value
will be overwritten.
Returns an iterator that can traverse over all key/value pairs (start from key
) in a bucket in sorted order.