BahDB is a fast relational database, built in Bah for Bah.
It is really simple to use and really shows how simple and elegant Bah can be.
- thread safe
- process safe
- scanning
- serializing
- indexing
- portable
The database interface.
db = bahDB{}
Used for mapping the database to a file.
db.open("path/to/my/database.db")
//database stuff
db.close()
Used for determining which elements must be affected.
condition = dbWhere("field", DB_EQUALS, value)
//means any element where element.field == value
Here is the list of all operations availables:
DB_EQUALS
DB_NOT_EQUALS
DB_GREATER
DB_LESS
DB_GREATER_EQUAL
DB_LESS_EQUAL
DB_LIKE
You can add multiple operations together by using the +
operator:
condition = dbWhere("field", DB_EQUALS, value) + dbWhere("field2", DB_LIKE, "%test%")
//means any element where element.field == value
//and element.field2 contains "test"
Used for updating a specified field of an object.
setter = dbSet("field", value)
//means any element where element.field = value
As operations, setters can be chained using the +
operator.
Used for inserting an element in the database.
myElem = new myStruct
db.insert(myElem)
Used for updating the content of an element inside the database.
template = new myStruct
db.update(condition, template, setter)
The template is used as a skeletton, only the fields presents in the template will be kepped.
Used for fetching the requested elements from the databse.
res = []myStruct*
db.select(condition, res)
Used for deleting elements from the database.
db.delete(condition)
There is an example of the database's usage in the file test.bah.
It is a simple command line interface for registering and managing messages.