Skip to the content.

Managing Foxx services

database.listServices

async database.listServices([excludeSystem]): Array<Object>

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Fetches a list of all installed service.

Arguments

Examples

const services = await db.listServices();

// -- or --

const services = await db.listServices(false);

database.installService

async database.installService(mount, source, [options]): Object

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Installs a new service.

Arguments

Examples

const source = fs.createReadStream("./my-foxx-service.zip");
const info = await db.installService("/hello", source);

// -- or --

const source = fs.readFileSync("./my-foxx-service.zip");
const info = await db.installService("/hello", source);

// -- or --

const element = document.getElementById("my-file-input");
const source = element.files[0];
const info = await db.installService("/hello", source);

database.replaceService

async database.replaceService(mount, source, [options]): Object

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Replaces an existing service with a new service by completely removing the old service and installing a new service at the same mount point.

Arguments

Examples

const source = fs.createReadStream("./my-foxx-service.zip");
const info = await db.replaceService("/hello", source);

// -- or --

const source = fs.readFileSync("./my-foxx-service.zip");
const info = await db.replaceService("/hello", source);

// -- or --

const element = document.getElementById("my-file-input");
const source = element.files[0];
const info = await db.replaceService("/hello", source);

database.upgradeService

async database.upgradeService(mount, source, [options]): Object

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Replaces an existing service with a new service while retaining the old service’s configuration and dependencies.

Arguments

Examples

const source = fs.createReadStream("./my-foxx-service.zip");
const info = await db.upgradeService("/hello", source);

// -- or --

const source = fs.readFileSync("./my-foxx-service.zip");
const info = await db.upgradeService("/hello", source);

// -- or --

const element = document.getElementById("my-file-input");
const source = element.files[0];
const info = await db.upgradeService("/hello", source);

database.uninstallService

async database.uninstallService(mount, [options]): void

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Completely removes a service from the database.

Arguments

Examples

await db.uninstallService("/my-service");
// service was uninstalled

database.getService

async database.getService(mount): Object

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Retrieves information about a mounted service.

Arguments

Examples

const info = await db.getService("/my-service");
// info contains detailed information about the service

database.getServiceConfiguration

async database.getServiceConfiguration(mount, [minimal]): Object

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Retrieves an object with information about the service’s configuration options and their current values.

Arguments

Examples

const config = await db.getServiceConfiguration("/my-service");
// config contains information about the service's configuration

database.replaceServiceConfiguration

async database.replaceServiceConfiguration(mount, configuration, [minimal]): Object

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Replaces the configuration of the given service.

Arguments

Examples

const config = { currency: "USD", locale: "en-US" };
const info = await db.replaceServiceConfiguration("/my-service", config);
// info.values contains information about the service's configuration
// info.warnings contains any validation errors for the configuration

database.updateServiceConfiguration

async database.updateServiceConfiguration(mount, configuration, [minimal]): Object

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Updates the configuration of the given service my merging the new values into the existing ones.

Arguments

Examples

const config = { locale: "en-US" };
const info = await db.updateServiceConfiguration("/my-service", config);
// info.values contains information about the service's configuration
// info.warnings contains any validation errors for the configuration

database.getServiceDependencies

async database.getServiceDependencies(mount, [minimal]): Object

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Retrieves an object with information about the service’s dependencies and their current mount points.

Arguments

Examples

const deps = await db.getServiceDependencies("/my-service");
// deps contains information about the service's dependencies

database.replaceServiceDependencies

async database.replaceServiceDependencies(mount, dependencies, [minimal]): Object

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Replaces the dependencies for the given service.

Arguments

Examples

const deps = { mailer: "/mailer-api", auth: "/remote-auth" };
const info = await db.replaceServiceDependencies("/my-service", deps);
// info.values contains information about the service's dependencies
// info.warnings contains any validation errors for the dependencies

database.updateServiceDependencies

async database.updateServiceDependencies(mount, dependencies, [minimal]): Object

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Updates the dependencies for the given service by merging the new values into the existing ones.

Arguments

Examples

const deps = { mailer: "/mailer-api" };
const info = await db.updateServiceDependencies("/my-service", deps);
// info.values contains information about the service's dependencies
// info.warnings contains any validation errors for the dependencies

database.enableServiceDevelopmentMode

async database.enableServiceDevelopmentMode(mount): Object

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Enables development mode for the given service.

Arguments

Examples

const info = await db.enableServiceDevelopmentMode("/my-service");
// the service is now in development mode
// info contains detailed information about the service

database.disableServiceDevelopmentMode

async database.disableServiceDevelopmentMode(mount): Object

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Disabled development mode for the given service and commits the service state to the database.

Arguments

Examples

const info = await db.disableServiceDevelopmentMode("/my-service");
// the service is now in production mode
// info contains detailed information about the service

database.listServiceScripts

async database.listServiceScripts(mount): Object

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Retrieves a list of the service’s scripts.

Returns an object mapping each name to a more readable representation.

Arguments

Examples

const scripts = await db.listServiceScripts("/my-service");
// scripts is an object listing the service scripts

database.runServiceScript

async database.runServiceScript(mount, name, [scriptArg]): any

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Runs a service script and returns the result.

Arguments

Examples

const result = await db.runServiceScript("/my-service", "setup");
// result contains the script's exports (if any)

database.runServiceTests

async database.runServiceTests(mount, [reporter]): any

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Runs the tests of a given service and returns a formatted report.

Arguments

Examples

const opts = { reporter: "xunit", idiomatic: true };
const result = await db.runServiceTests("/my-service", opts);
// result contains the XUnit report as a string

database.downloadService

async database.downloadService(mount): Buffer | Blob

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Retrieves a zip bundle containing the service files.

Returns a Buffer in Node or Blob in the browser version.

Arguments

Examples

const bundle = await db.downloadService("/my-service");
// bundle is a Buffer/Blob of the service bundle

database.getServiceReadme

async database.getServiceReadme(mount): string?

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Retrieves the text content of the service’s README or README.md file.

Returns undefined if no such file could be found.

Arguments

Examples

const readme = await db.getServiceReadme("/my-service");
// readme is a string containing the service README's
// text content, or undefined if no README exists

database.getServiceDocumentation

async database.getServiceDocumentation(mount): Object

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Retrieves a Swagger API description object for the service installed at the given mount point.

Arguments

Examples

const spec = await db.getServiceDocumentation("/my-service");
// spec is a Swagger API description of the service

database.commitLocalServiceState

async database.commitLocalServiceState([replace]): void

Note: This method is only available when targeting ArangoDB 3.2 or later, see Compatibility.

Writes all locally available services to the database and updates any service bundles missing in the database.

Arguments

Examples

await db.commitLocalServiceState();
// all services available on the coordinator have been written to the db

// -- or --

await db.commitLocalServiceState(true);
// all service conflicts have been resolved in favor of this coordinator