compact (NotesDatabase - JavaScript)

Compacts a local database.

Defined in

NotesDatabase

Syntax

compact() : int
Return value Description
int The difference in bytes between the size of the database before and after compacting.

Usage

This method throws an exception if the database is not local.

Examples

This button compacts a database if it is less than 80 percent used.
var dbname:string = requestScope.filename;
var db:NotesDatabase = session.getDatabase("", dbname, false);
if (db == null) {
	requestScope.status = "Cannot open database " + dbname;
	return;
}
var title:string = db.getTitle();
var percentUsed:double = db.getPercentUsed();
if (percentUsed < 80) {
	var saved:int = db.compact();
	requestScope.status = "Compacting database '" + title + "'\n";
}
requestScope.status += "Database '" + title + "' is " + percentUsed + " percent used";