DataService (JavaScript)

Used to help in the development of XPages applications running on Bluemix. The DataService object is based on the Java class com.ibm.xsp.bluemix.util.context.BluemixContext.DataService. This object provides methods to retrieve information about the bound XPages NoSQL Database Service from the VCAP_SERVICES environment.

Retrieving information about the DataService object

The bluemixContext object getDataService and getDataServiceByName methods return the DataService object. This object provides methods to retrieve information about the bound XPages NoSQL Database Service from the VCAP_SERVICES environment variables. The available methods include the following:

findDatabaseName() : String
Returns the database name associated with the bound service being queried.
atDbName() : Vector<String>
Can used as a substitute for the @DbName() at-function. @DbName() and atDbName() are commonly used with the @DbLookup and @DbColumn at-functions.
getAppPath() : String
Returns the application location path of the database associated with the bound service.
getCredentialsValue(String) : String
Returns the credential values of the database associated with the bound service.
getHost() : String
Returns the name of the host associated with the application using the bound service.
getLabel() : String
Returns the label that was assigned to the application associated with the bound service.
getPlan() : String
Returns the Bluemix service plan assigned to the application associated with the bound service.
getRootDir() : String
Returns the root directory information related to the application associated with the bound service.
getServerName() : String
Returns the hosting server name information related to the application associated with the bound service.
getUserName() : String
Returns the user name information related to the application associated with the bound service.
getValue(String) : String
Can be used as an alternative to return the same values as getName(), getLabel(), and getPlan(). The method looks directly at the values in the VCAP_SERVICES environment variable.

For detailed descriptions of the VCAP_SERVICES environment variables, refer to the Bluemix documentation on environment variables for more information.