# Class: FileDatabase

## jala.db.FileDatabase(name, directory, username, password)

Instances of this class represent a file based in-process database
Important: You need the h2.jar in directory "lib/ext" of your helma installation for this library to work, which you can get at http://www.h2database.com/.

## Constructor

#### new FileDatabase(name, directory, username, password)

Returns a newly created instance of FileDatabase.

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | String | The name of the database. This name is used as prefix for all database files
`directory` | helma.File | The directory where the database files should be stored in.
`username` | String | Optional username (defaults to "sa"). This username is used when creating the database, so the same should be used when creating subsequent instances of jala.db.FileDatabase pointing to the same database
`password` | String | Optional password (defaults to "").

Source:
  - jala/code/Database.js, line 985

##### Returns:

A newly created FileDatabase instance

### Methods

#### backup(file)

Creates a backup of this database, using the file passed as argument. The result will be a zipped file containing the database files

##### Parameters:

Name | Type | Description
--- | --- | ---
`file` | helma.File | The file to write the backup to

Source:
  - jala/code/Database.js, line 1085

##### Returns:

True if the database backup was created successfully, false otherwise

#### getDirectory()

Returns the directory where the database files are stored.

Source:
  - jala/code/Database.js, line 1002

##### Returns:

The directory where this database is stored.

#### getName()

Returns the name of the database. This name is used as prefix for all files of this database in the specified directory

Source:
  - jala/code/Database.js, line 993

##### Returns:

The name of the database

#### getPassword()

Returns the password of this database

Source:
  - jala/code/Database.js, line 1020

##### Returns:

The password of this database

#### getUsername()

Returns the username of this database

Source:
  - jala/code/Database.js, line 1011

##### Returns:

The username of this database

#### remove()

Deletes all files of this database on disk. Note that this also closes the database before removing it.

Source:
  - jala/code/Database.js, line 1060

##### Returns:

True in case the database was removed successfully, false otherwise

#### restore(backupFile)

Restores this database using a backup on disk.

##### Parameters:

Name | Type | Description
--- | --- | ---
`backupFile` | helma.File | The backup file to use for restore

Source:
  - jala/code/Database.js, line 1107

##### Returns:

True if the database was successfully restored, false otherwise