Interface QDB
access this type via: data.qdb.QDB (provides, requires or uses)
This is a simple database, written in Dana, which has a schema and query interface matching Dana data types.
Functions
QDB(char directory[])
bool addTable(char name[], Data schema, bool autoKey, bool reuseKeys)
String[] getTables()
Data getTableSchema(char name[])
void remTable(char name[])
char[] addRow(char table[], char rowKey[], Data rowData)
char[] addRowAuto(char table[], Data rowData)
void updRow(char table[], char rowKey[], Data rowData)
void addUpdRow(char table[], char rowKey[], Data rowData)
Data getRow(char table[], char rowKey[])
void remRow(char table[], char rowKey[])
int incField(char table[], char rowKey[], TypeField index)
int decField(char table[], char rowKey[], TypeField index)
RowData[] getRows(char table[])
RowData[] getRowsClear(char table[])
RowData getRowEq(char table[], TypeField index, Data template)
RowData[] getRowsEq(char table[], TypeField index, Data template)
void remRowEq(char table[], TypeField index, Data template)
void remRowsEq(char table[], TypeField index, Data template)
QDB(char directory[])
Create a new database instance, using the given directory to store all associated files.
bool addTable(char name[], Data schema, bool autoKey, bool reuseKeys)
Add a new table to the database.
name The name of the table; each table name in the database must be unique.
schema The row schema for this table. For maximum compatibility, it is good practice if a schema only contains size-specific fields (i.e., do not use 'int' or 'dec', instead using size-specific types such as 'int8'). Schemas cannot have fields of data or object types.
autoKey Set whether this table should automatically generate keys for new rows.
reuseKeys If autoKey is true, set whether this table should re-use old keys from rows that have been deleted.
returns: True if the table addition was successful, false otherwise.
String[] getTables()
Get the list of all tables in the database.
Data getTableSchema(char name[])
Get the schema for the specified table.
void remTable(char name[])
Remove the specified table and all of its associated data.
char[] addRow(char table[], char rowKey[], Data rowData)
Add a new row to a table. The rowData instance must match the table's schema. The rowKey is only used for tables with no autoKey. The key for the new row is returned.
char[] addRowAuto(char table[], Data rowData)
Add a new row to a table which has autoKey set. The key for the new row is returned.
void updRow(char table[], char rowKey[], Data rowData)
Update a specific row in a table. The rowData instance must match the table's schema.
void addUpdRow(char table[], char rowKey[], Data rowData)
Add a new row to a table, or update that row if it already exists.
Data getRow(char table[], char rowKey[])
Get the row for the given key.
void remRow(char table[], char rowKey[])
Remove the row for the given key.
int incField(char table[], char rowKey[], TypeField index)
For a given row, increment the field given by index. If no such row exists one is created with all fields set to zero/empty.
int decField(char table[], char rowKey[], TypeField index)
For a given row, decrement the field given by index (if any such row exists).
RowData[] getRows(char table[])
Get all rows for a given table. This operation may be very expensive for large tables.
RowData[] getRowsClear(char table[])
Get all rows for a given table and then delete those rows.
RowData getRowEq(char table[], TypeField index, Data template)
Get the first row where the given field index matches that of the given template.
RowData[] getRowsEq(char table[], TypeField index, Data template)
Get all rows where the given field index matches that of the given template.
void remRowEq(char table[], TypeField index, Data template)
Remove the first row where the given field index matches that of the given template.
void remRowsEq(char table[], TypeField index, Data template)
Remove all rows where the given field index matches that of the given template.