# BDBDatabase

## Abstract

Wrapper for a DB instance

## Discussion

Use instances of this class to load/store values

## Methods

`-appendEntry`
  appends the given entry to the end of the database
`-appendEntryWithTransaction:entryToAppend:resultingRecordNr:`
  appends the given entry to the end of the database
`-close`
`-deleteEntryWithTransaction`
`-deleteEntryWithTransaction:key:`
`-getEntryWithTransaction`
  retriev a value by its record number
`-getEntryWithTransaction:recordNumber:data:`
  retriev a value by its record number
`+initWithFilename`
  open a database with the given file name, database name and configuration.
`+initWithFilename:databaseName:databaseConfig:`
  open a database with the given file name, database name and configuration.
`-openCursor`
  open and return a cursor used.
`-openCursor:cursorConfig:`
  open and return a cursor used.
`-putDataWithTransaction:key:value:`
`-putEntryWithTransaction`
  Stores an entry in the database.
`-putEntryWithTransaction:key:value:`
  Stores an entry in the database.

### appendEntry

appends the given entry to the end of the database

See Also:

> appendEntryWithTransaction:entryToAppend:resultingRecordNr:

>     - (BDBOperationStatus) appendEntryWithTransaction: (BDBTransaction *) transaction entryToAppend: (BDBDatabaseEntryData *) entryToAppend resultingRecordNr: (BDBDatabaseRecordNumber *) recordNr;

##### Parameter Descriptions

> `transaction`
>   transaction to use
> `entryToAppend`
>   value to add
> `recordNr`
>   will contain the record number after appending the value. The underlying database entry instance has to be instantiated by the caller. If nil is passed then no record number will be returned this way.

method result
  status of the operation

##### Discussion

This method is only defined for one of the modes ``, ``

### appendEntryWithTransaction:entryToAppend:resultingRecordNr:

appends the given entry to the end of the database

See Also:

> appendEntry

>     - (BDBOperationStatus) appendEntryWithTransaction: (BDBTransaction *) transaction entryToAppend: (BDBDatabaseEntryData *) entryToAppend resultingRecordNr: (BDBDatabaseRecordNumber *) recordNr;

##### Parameter Descriptions

> `transaction`
>   transaction to use
> `entryToAppend`
>   value to add
> `recordNr`
>   will contain the record number after appending the value. The underlying database entry instance has to be instantiated by the caller. If nil is passed then no record number will be returned this way.

##### Discussion

This method is only defined for one of the modes ``, ``

### close

>     - close;

##### Discussion

Closes the database. After this call all settings related to the database are being invalidated. The previously hand-off configuration may be reused.

### deleteEntryWithTransaction

See Also:

> deleteEntryWithTransaction:key:

>     - (BDBOperationStatus) deleteEntryWithTransaction:( BDBTransaction *) transaction key: (BDBDatabaseEntryData *) key;

##### Parameter Descriptions

> `transaction`
> `key`
>   key specifying the entry to be deleted

method result
  status which may equal BDB_STATUS_NOTFOUND, BDB_STATUS_KEYEMPTY or BDB_STATUS_SUCCESS

##### Discussion

In case of duplicate entries specified by the key all entries will be removed.

### deleteEntryWithTransaction:key:

See Also:

> deleteEntryWithTransaction

>     - (BDBOperationStatus) deleteEntryWithTransaction:( BDBTransaction *) transaction key: (BDBDatabaseEntryData *) key;

##### Parameter Descriptions

> `transaction`
> `key`
>   key specifying the entry to be deleted

##### Discussion

In case of duplicate entries specified by the key all entries will be removed.

### getEntryWithTransaction

retriev a value by its record number

See Also:

> getEntryWithTransaction:recordNumber:data:

>     - (BDBOperationStatus) getEntryWithTransaction: (BDBTransaction *) transaction recordNumber: (BDBDatabaseRecordNumber *) recNo data: (BDBDatabaseEntryData *) data;

##### Parameter Descriptions

> `transaction`
>   underlying transaction. May equal nil
> `key`
>   key to look for
> `data`
>   entry to fill with the found data entry

method result
  status of the operation

### getEntryWithTransaction:recordNumber:data:

retriev a value by its record number

See Also:

> getEntryWithTransaction

>     - (BDBOperationStatus) getEntryWithTransaction: (BDBTransaction *) transaction recordNumber: (BDBDatabaseRecordNumber *) recNo data: (BDBDatabaseEntryData *) data;

##### Parameter Descriptions

> `transaction`
>   underlying transaction. May equal nil
> `key`
>   key to look for
> `data`
>   entry to fill with the found data entry

### initWithFilename

open a database with the given file name, database name and configuration.

See Also:

> initWithFilename:databaseName:databaseConfig:

>     + (BDBDatabase *) initWithFilename: (NSString *) fileName databaseName: (NSString *) databaseName databaseConfig: (BDBDatabaseConfig *) aDbConfig;

##### Parameter Descriptions

> `fileName`
>   name of database file
> `databaseName`
>   name of database. Useful if multiple databases will be used within a single file. May equal nil. If nil is given during creation then subsequent calls with values different from nil will be ignored.
> `aDbConfig`
>   configuration parameters

##### Discussion

Depending on the configuration the database may be created if not existent. Also, the configuration determines the kind of database to use.

### initWithFilename:databaseName:databaseConfig:

open a database with the given file name, database name and configuration.

See Also:

> initWithFilename

>     + (BDBDatabase *) initWithFilename: (NSString *) fileName databaseName: (NSString *) databaseName databaseConfig: (BDBDatabaseConfig *) aDbConfig;

##### Parameter Descriptions

> `fileName`
>   name of database file
> `databaseName`
>   name of database. Useful if multiple databases will be used within a single file. May equal nil. If nil is given during creation then subsequent calls with values different from nil will be ignored.
> `aDbConfig`
>   configuration parameters

##### Discussion

Depending on the configuration the database may be created if not existent. Also, the configuration determines the kind of database to use.

### openCursor

open and return a cursor used.

See Also:

> openCursor:cursorConfig:

>     - (BDBCursor *) openCursor: (BDBTransaction *) transaction cursorConfig: (BDBCursorConfig *) config;

##### Parameter Descriptions

> `transaction`
>   underlying transaction. May be nil
> `config`
>   settings for the cursor to be created ®result related cursor

### openCursor:cursorConfig:

open and return a cursor used.

See Also:

> openCursor

>     - (BDBCursor *) openCursor: (BDBTransaction *) transaction cursorConfig: (BDBCursorConfig *) config;

##### Parameter Descriptions

> `transaction`
>   underlying transaction. May be nil
> `config`
>   settings for the cursor to be created ®result related cursor

### putDataWithTransaction:key:value:

>     - (BDBOperationStatus) putDataWithTransaction: (BDBTransaction *) transaction key: (NSData *) key value: (NSData *) value;

##### Parameter Descriptions

> `key`
>   may not be null. The handling of duplicates depends on the the configuration previously being set.
> `value`
>   may not be null.

##### Discussion

Stores an entry in the database

### putEntryWithTransaction

Stores an entry in the database.

See Also:

> putEntryWithTransaction:key:value:

>     - (BDBOperationStatus) putEntryWithTransaction: (BDBTransaction *) transaction key: (BDBDatabaseEntryData *) key value: (BDBDatabaseEntryData *) value;

##### Parameter Descriptions

> `key`
>   value for the key to be used. The handling of duplicates depends on the the configuration previously being set.
> `value`

method result
  status of operation

### putEntryWithTransaction:key:value:

Stores an entry in the database.

See Also:

> putEntryWithTransaction

>     - (BDBOperationStatus) putEntryWithTransaction: (BDBTransaction *) transaction key: (BDBDatabaseEntryData *) key value: (BDBDatabaseEntryData *) value;

##### Parameter Descriptions

> `key`
>   value for the key to be used. The handling of duplicates depends on the the configuration previously being set.
> `value`

(Last Updated August 27, 2006)