Interface Client
access this type via: data.qdb.Client (provides, requires or uses)
This is a client program to communicate with a QDB instance over a network.
Functions
Client(optional char password[])
bool connect(char host[], int port)
void disconnect()
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)
Client(optional char password[])
Instantiate a new database client instance, optionally providing a password as a key for encrypted communication. If no password is provided then all communication will be in plain text.
bool connect(char host[], int port)
Connect to the database server on the specified host and port number.
void disconnect()
Disconnect from the database server.
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 'int4'. Schemes 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 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.