Would you like to contribute to the Titanium docs? To get started, sign up for an account on the Appcelerator Wiki and sign our CLA.

Skip to end of metadata
Go to start of metadata

Introduction

Connectors give your applications the ability to access external data from different sources, such as from a database or in the cloud. To add a Connector:

  1. Install the Connector.
  2. Configure the Connector.
  3. Use the Connector.

Search for connectors

To see an available list of Connectors, either use the appc search command or go to the Appcelerator Marketplace to search for connectors.

Install a connector

To install a connector, execute the appc install connector/<CONNECTOR_NAME> command from the project's directory. The command downloads and installs the connector to the node_modules/connector directory, updates the appc.json file, and creates a connector configuration file in the project's conf directory.

Configure the connector

Depending on the connector you installed, you may need to modify the configuration settings of the connector. Open the project's conf/<CONNECTOR_NAME>.js file to modify its settings. Some connectors have multiple files for different deployment environments, such as the appc.arrowdb connector. For example, the MySQL connector's configuration file contains keys for you to define the database host URL, port number, admin user, admin password, and database name as well as additional database access settings.

conf/appc.mysql.default.js

Disable API endpoints

By default, when you install a connector, it will add its API endpoints to the application, for example, api/myconnector/model. If you do not want to generate these API endpoints, set the modelAutogen key to false in the connector's configuration file in the project.

conf/myconnector.default.js

Use the connector

To use the connector, simply assign the connector key in a Model file to the name of the connector. For example, the model file below is using the employee table (or model) accessed by the MySQL connector.

models/employee.js

Remove a connector

To remove a connector from your project, you need to manually update the appc.json file and remove some files.

  1. Open the appc.json file and delete the connector you want to remove from the dependencies object. For example, if you want to remove the MySQL connector, remove the "connector/appc.mysql": "^1.0.34". Note that you will need to remove the trailing comma at the end of the arrowdb line.

  2. Delete the connector's configuration file(s) from the project conf directory.  The file(s) will contain the name of the connector.
  3. Delete the connector's directory in the node_modules/connectors/ directory.  The directory will contain the name of the connector.