The Informix connector enables LoopBack applications to connect to Informix data sources.Note: This page was generated from the loopback-connector-informix/README.md.

loopback-connector-informix

IBM® Informix® is the database of choice for robust, enterprise-wide solutions handling high-volume workloads.It is optimized to deliver industry-leading performance while lowering costs. The loopback-connector-informix module is the LoopBack connector for Informix.

The LoopBack Informix connector supports:

Installation

Enter the following in the top-level directory of your LoopBack application:

  1. $ npm install loopback-connector-informix --save

The —save option adds the dependency to the application’s package.json file.

Configuration

Use the data source generator to add the Informix data source to your application.The resulting entry in the application’s server/datasources.json will look something like this:

  1. "mydb": {
  2. "name": "mydb",
  3. "connector": "informix"
  4. }

Edit server/datasources.json to add other supported properties as required:

  1. "mydb": {
  2. "name": "mydb",
  3. "connector": "informix",
  4. "username": <username>,
  5. "password": <password>,
  6. "database": <database name>,
  7. "hostname": <informix server hostname>,
  8. "port": <port number>
  9. }

The following table describes the connector properties.

PropertyTypeDescription
databaseStringDatabase name
schemaStringSpecifies the default schema name that is used to qualify unqualified database objects in dynamically prepared SQL statements. The value of this property sets the value in the CURRENT SCHEMA special register on the database server. The schema name is case-sensitive, and must be specified in uppercase characters
usernameStringInformix Username
passwordStringInformix password associated with the username above
hostnameStringInformix server hostname or IP address
portStringInformix server TCP port number

Alternatively, you can create and configure the data source in JavaScript code.For example:

  1. var DataSource = require('loopback-datasource-juggler').DataSource;
  2. var Informix = require('loopback-connector-informix');
  3. var config = {
  4. username: process.env.INFORMIX_USERNAME,
  5. password: process.env.INFORMIX_PASSWORD,
  6. hostname: process.env.INFORMIX_HOSTNAME,
  7. port: 50000,
  8. database: 'informixdb',
  9. };
  10. var db = new DataSource(Informix, config);
  11. var User = db.define('User', {
  12. name: { type: String },
  13. email: { type: String },
  14. });
  15. db.autoupdate('User', function(err) {
  16. if (err) {
  17. console.log(err);
  18. return;
  19. }
  20. User.create({
  21. name: 'Tony',
  22. email: 'tony@t.com',
  23. }, function(err, user) {
  24. console.log(err, user);
  25. });
  26. User.find({ where: { name: 'Tony' }}, function(err, users) {
  27. console.log(err, users);
  28. });
  29. User.destroyAll(function() {
  30. console.log('example complete');
  31. });
  32. });

Running tests

Own instance

If you have a local or remote Informix instance and would like to use that to run the test suite, use the following command:

  • Linux
  1. INFORMIX_HOSTNAME=<HOST> INFORMIX_PORTNUM=<PORT> INFORMIX_USERNAME=<USER> INFORMIX_PASSWORD=<PASSWORD> INFORMIX_DATABASE=<DATABASE> INFORMIX_PROTOCOL=<PROTOCOL> INFORMIX_SERVER=<SERVER> INFORMIX_DRIVER=<DRIVER> INFORMIX_AUTH=<AUTH> CI=true npm test
  • Windows
  1. SET INFORMIX_HOSTNAME=<HOST>
  2. SET INFORMIX_PORTNUM=<PORT>
  3. SET INFORMIX_USERNAME=<USER>
  4. SET INFORMIX_PASSWORD=<PASSWORD>
  5. SET INFORMIX_DATABASE=<DATABASE>
  6. SET INFORMIX_PROTOCOL=<PROTOCOL>
  7. SET INFORMIX_SERVER=<SERVER>
  8. SET INFORMIX_DRIVER=<DRIVER>
  9. SET INFORMIX_AUTH=<AUTH>
  10. SET CI=true
  11. npm test

Docker

If you do not have a local Informix instance, you can also run the test suite with very minimal requirements.

  • Assuming you have Docker installed, run the following script which would spawn an Informix instance on your local:
  1. source setup.sh
  • Run the test:
  1. npm test

Tags: connectorsreadme