getFirstDatabase (NotesDbDirectory - JavaScript)

Returns the first database from a server or the local directory, using the file type you specify.

Defined in

NotesDbDirectory

Syntax

getFirstDatabase(type:int) : NotesDatabase
Parameter Description
type Indicates the kind of database file you want to retrieve:
  • NotesDbDirectory.DATABASE 1247 for a database (NSF, NSG, or NSH file)
  • TEMPLATE 1248 for a template (NTF file)
  • REPLICA_CANDIDATE 1245 for a replica candidate (any database or template not disabled for replication)
  • TEMPLATE_CANDIDATE 1246 for a template candidate (any database or template)
Return value Description
NotesDatabase The first database of the specified file type located in the directory, or null if the directory contains no databases of the specified type.

Usage

The returned database is closed. If you do not open the database, only a subset of its methods are available. See isOpen in NotesDatabase.

Each time you call this method, the database directory is reset and a new search is conducted. If you are searching for template files, for example, a new call to getFirstDatabase with the parameter NotesDbDirectory.DATABASE starts searching the directory from the beginning, this time for database files.

Examples

This data binding for a list box displays the names of all the databases in the current directory.
var out = "";
var dir = session.getDbDirectory("");
var db = dir.getFirstDatabase(NotesDbDirectory.DATABASE);
while (db != null) {
	out = out + db.getFileName() + "\n";
	var tmpdb = dir.getNextDatabase();
	db.recycle();
	db = tmpdb;
}
return out