Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

loopback-connector-mysql

loopbackio28.6kMIT7.1.2

MySQL connector for loopback-datasource-juggler

readme

loopback-connector-mysql

MySQL is a popular open-source relational database management system (RDBMS). The loopback-connector-mysql module provides the MySQL connector module for the LoopBack framework.

Installation

In your application root directory, enter this command to install the connector:

npm install loopback-connector-mysql --save

Note: Since loopback-connector-mysql v7.x.x, this MySQL connector has dropped support for MySQL 5.7 and requires MySQL 8.0+.

This installs the module from npm and adds it as a dependency to the application's package.json file.

If you create a MySQL data source using the data source generator as described below, you don't have to do this, since the generator will run npm install for you.

Creating a MySQL data source

For LoopBack 4 users, use the LoopBack 4 Command-line interface to generate a DataSource with MySQL connector to your LB4 application. Run lb4 datasource, it will prompt for configurations such as host, post, etc. that are required to connect to a MySQL database.

After setting it up, the configuration can be found under src/datasources/<DataSourceName>.datasource.ts, which would look like this:

const config = {
  name: 'db',
  connector: 'mysql',
  url: '',
  host: 'localhost',
  port: 3306,
  user: 'user',
  password: 'pass',
  database: 'testdb',
};
<summary markdown="span">For LoopBack 3 users</summary>

Use the Data source generator to add a MySQL data source to your application.
The generator will prompt for the database server hostname, port, and other settings required to connect to a MySQL database. It will also run the npm install command above for you.

The entry in the application's /server/datasources.json will look like this:

"mydb": {
  "name": "mydb",
  "connector": "mysql",
  "host": "myserver",
  "port": 3306,
  "database": "mydb",
  "password": "mypassword",
  "user": "admin"
 }

Edit <DataSourceName>.datasources.ts to add any other additional properties that you require.

Properties

Property Type Description
collation String Determines the charset for the connection. Default is utf8_general_ci.
connector String Connector name, either “loopback-connector-mysql” or “mysql”.
connectionLimit Number The maximum number of connections to create at once. Default is 10.
database String Database name
debug Boolean If true, turn on verbose mode to debug database queries and lifecycle.
host String Database host name
password String Password to connect to database
port Number Database TCP port
socketPath String The path to a unix domain socket to connect to. When used host and port are ignored.
supportBigNumbers Boolean Enable this option to deal with big numbers (BIGINT and DECIMAL columns) in the database. Default is false.
timeZone String The timezone used to store local dates. Default is ‘local’.
url String Connection URL of form mysql://user:password@host/db. Overrides other connection settings.
username String Username to connect to database
allowExtendedOperators Boolean Set to true to enable MySQL-specific operators such as match. Learn more in Extended operators below.

NOTE: In addition to these properties, you can use additional parameters supported by node-mysql.

Type mappings

See LoopBack 4 types (or LoopBack 3 types) for details on LoopBack's data types.

LoopBack to MySQL types

LoopBack Type MySQL Type
String/JSON VARCHAR
Text TEXT
Number INT
Date DATETIME
Boolean TINYINT(1)
GeoPoint object POINT
Custom Enum type
(See Enum below)
ENUM

MySQL to LoopBack types

MySQL Type LoopBack Type
CHAR String
BIT(1)
CHAR(1)
TINYINT(1)
Boolean
VARCHAR
TINYTEXT
MEDIUMTEXT
LONGTEXT
TEXT
ENUM
SET
String
TINYBLOB
MEDIUMBLOB
LONGBLOB
BLOB
BINARY
VARBINARY
BIT
Node.js Buffer object
TINYINT
SMALLINT
INT
MEDIUMINT
YEAR
FLOAT
DOUBLE
NUMERIC
DECIMAL

Number
For FLOAT and DOUBLE, see Floating-point types.

For NUMERIC and DECIMAL, see Fixed-point exact value types

DATE
TIMESTAMP
DATETIME
Date

NOTE as of v3.0.0 of MySQL Connector, the following flags were introduced:

  • treatCHAR1AsString default false - treats CHAR(1) as a String instead of a Boolean
  • treatBIT1AsBit default true - treats BIT(1) as a Boolean instead of a Binary
  • treatTINYINT1AsTinyInt default true - treats TINYINT(1) as a Boolean instead of a Number

Data mapping properties

Except the common database-specific properties we introduce in How LoopBack Models Map To Database Tables/Collections, the following are more detailed examples and MySQL-specific settings.

Table/Column Names

Besides the basic LoopBack types, as we introduced above, you can also specify additional MySQL-specific properties for a LoopBack model. It would be mapped to the database.

Use the mysql.<property> in the model definition or the property definition to configure the table/column definition.

For example, the following settings would allow you to have custom table name (Custom_User) and column name (custom_id and custom_name). Such mapping is useful when you'd like to have different table/column names from the model:

{% include code-caption.html content="user.model.ts" %}

@model({
  settings: { mysql: { schema: 'testdb', table: 'Custom_User'} },
})
export class User extends Entity {
  @property({
    type: 'number',
    required: true,
    id: true,
    mysql: {
      columnName: 'custom_id',
    },
  })
  id: number;

  @property({
    type: 'string',
    mysql: {
      columnName: 'custom_name',
    },
  })
  name?: string;
<summary markdown="span">For LoopBack 3 users</summary>
{
  "name": "User",
  "options": {
    "mysql": {
      "schema": "testdb",
      "table": "Custom_User"
    }
  },
  "properties": {
    "id": {
      "type": "Number",
      "required": true,
      "mysql": {
        "columnName": "custom_id",
      }
    },
    "name": {
      "type": "String",
      "mysql": {
        "columnName": "custom_name",
      }
    },
  }
}

Numeric Types

Except the names, you can also use the dataType column/property attribute to specify what MySQL column type to use. The following MySQL type-dataType combinations are supported:

  • number
  • integer
  • tinyint
  • smallint
  • mediumint
  • int
  • bigint
  • float
  • double
  • decimal

The following examples will be in LoopBack 4 style, but it's the same if you provide mysql.<property> to the LB3 property definition.

Floating-point types

For Float and Double data types, use the precision and scale options to specify custom precision. Default is (16,8).

<summary markdown="span">Example</summary>
@property({
  type: 'Number',
  mysql: {
    dataType: 'float',
    precision: 20,
    scale: 4
  }
})
price: Number;

Fixed-point exact value types

For Decimal and Numeric types, use the precision and scale options to specify custom precision. Default is (9,2). These aren't likely to function as true fixed-point.

<summary markdown="span">Example</summary>
@property({
  type: 'Number',
  mysql: {
    dataType: 'decimal',
    precision: 12,
    scale: 8
  }
})
price: Number;

Text types

Convert String / DataSource.Text / DataSource.JSON to the following MySQL types:

  • varchar
  • char
  • text
  • mediumtext
  • tinytext
  • longtext
<summary markdown="span">Example</summary>
@property({
  type: 'String',
  mysql: {
    dataType: 'char',
    dataLength: 24 // limits the property length
  },
})
userName: String;

Dat types

Convert JSON Date types to datetime or timestamp.

<summary markdown="span">Example</summary>
@property({
  type: 'Date',
  mysql: {
    dataType: 'timestamp',
  },
})
startTime: Date;

Enum

See the Model ENUM property for details.

Default Clause/Constant

Use the default and dataType properties to have MySQL handle setting column DEFAULT value.

<summary markdown="span">Example</summary>
@property({
  type: 'String',
  mysql: {
    dataType: 'varchar',
    default: 'pending'
  }
})
status: String;

@property({
  type: 'Number',
  mysql: {
    dataType: 'int',
    default: 42
  }
})
maxDays: Number;

@property({
  type: 'boolean',
  mysql: {
    dataType: 'tinyint',
    default: 1
  }
})
isDone: Boolean;

For the date or timestamp types use CURRENT_TIMESTAMP or now.

<summary markdown="span">Example</summary>
@property({
  type: 'Date',
  mysql: {
    dataType: 'datetime',
    default: 'CURRENT_TIMESTAMP'
  }
})
last_modified: Date;

NOTE: The following column types do NOT supported MySQL Default Values:

  • BLOB
  • TEXT
  • GEOMETRY
  • JSON

Extended operators

MySQL connector supports the following MySQL-specific operators:

  • match Please note extended operators are disabled by default, you must enable them at datasource level or model level by setting allowExtendedOperators to true.

    Operator match

    The match operator allows you to perform a full text search using the MATCH() .. AGAINST() operator in MySQL.

Three different modes of the MATCH clause are also available in the form of operators -

By default, the match operator works in Natural Language mode.

Note The fields you are querying must be setup with a FULLTEXT index to perform full text search on them. Assuming a model such as this:

@model({
  settings: {
    allowExtendedOperators: true,
  }
})
class Post {
  @property({
    type: 'string',
    mysql: {
      index: {
        kind: 'FULLTEXT'
      }
    },
  })
  content: string;
}

You can query the content field as follows:

const posts = await postRepository.find({
  where: {
    {
      content: {match: 'someString'},
    }
  }
});

Discovery and auto-migration

Model discovery

The MySQL connector supports model discovery that enables you to create LoopBack models based on an existing database schema. Once you defined your datasource:

Auto-migration

The MySQL connector also supports auto-migration that enables you to create a database schema from LoopBack models. For example, based on the following model, the auto-migration method would create/alter existing Customer table in the database. Table Customer would have two columns: name and id, where id is also the primary key that has auto_increment set as it has definition of type: 'Number' and generated: true:

@model()
export class Customer extends Entity {
  @property({
    id: true,
    type: 'Number',
    generated: true,
  })
  id: number;

  @property({
    type: 'string',
  })
  name: string;
}

Moreover, additional MySQL-specific properties mentioned in the Data mapping properties section work with auto-migration as well.

Auto-generated ids

For now LoopBack MySQL connector only supports auto-generated id (generated: true) for integer type as for MySQL, the default id type is integer. If you'd like to use other types such as string (uuid) as the id type, you can:

  • use uuid that is generated by your LB application by setting defaultFn: uuid.
  @property({
    id: true,
    type: 'string'
    defaultFn: 'uuidv4',
    // generated: true,  -> not needed
  })
  id: string;
  • Alter the table in your database to use a certain function if you prefer having the database to generate the value.
  @property({
    id: true,
    type: 'string'
    generated: true,  // to indicate the value generates by the db
    useDefaultIdType: false,  // needed
  })
  id: string;

Auto-migrate/Auto-update models with foreign keys

Foreign key constraints can be defined in the model definition.

Note: The order of table creation is important. A referenced table must exist before creating a foreign key constraint. The order can be specified using the optional SchemaMigrationOptions argument of migrateSchema:

await app.migrateSchema({
    models: [ 'Customer', 'Order' ]
});

Define your models and the foreign key constraints as follows:

{% include code-caption.html content="customer.model.ts" %}

@model()
export class Customer extends Entity {
  @property({
    id: true,
    type: 'Number',
    generated: true,
  })
  id: number;

  @property({
    type: 'string',
  })
  name: string;
}

order.model.ts:

@model({
  settings: {
    foreignKeys: {
      fk_order_customerId: {
        name: 'fk_order_customerId',
        entity: 'Customer',
        entityKey: 'id',
        foreignKey: 'customerId',
      },
    },
  })
export class Order extends Entity {
  @property({
    id: true,
    type: 'Number',
    generated: true
  })
  id: number;

  @property({
    type: 'string'
  })
  name: string;

  @property({
    type: 'Number'
  })
  customerId: number;
}
<summary markdown="span">For LoopBack 3 users</summary>
({
  "name": "Customer",
  "options": {
    "idInjection": false
  },
  "properties": {
    "id": {
      "type": "Number",
      "id": 1
    },
    "name": {
      "type": "String",
      "required": false
    }
  }
},
{
  "name": "Order",
  "options": {
    "idInjection": false,
    "foreignKeys": {
      "fk_order_customerId": {
        "name": "fk_order_customerId",
        "entity": "Customer",
        "entityKey": "id",
        "foreignKey": "customerId"
      }
    }
  },
  "properties": {
    "id": {
      "type": "Number"
      "id": 1
    },
    "customerId": {
      "type": "Number"
    },
    "description": {
      "type": "String",
      "required": false
    }
  }
})

MySQL handles the foreign key integrity by the referential action specified by ON UPDATE and ON DELETE. You can specify which referential actions the foreign key follows in the model definition upon auto-migrate or auto-update operation. Both onDelete and onUpdate default to restrict.

Take the example we showed above, let's add the referential action to the foreign key customerId:

@model({
  settings: {
    foreignKeys: {
      fk_order_customerId: {
        name: 'fk_order_customerId',
        entity: 'Customer',
        entityKey: 'id',
        foreignKey: 'customerId',
        onUpdate: 'restrict', // restrict|cascade|set null|no action|set default
        onDelete: 'cascade'   // restrict|cascade|set null|no action|set default
      },
    },
  })
export class Order extends Entity {
...
<summary markdown="span">For LoopBack 3 users</summary>

model-definiton.json

{
  "name": "Customer",
  "options": {
    "idInjection": false
  },
  "properties": {
    "id": {
      "type": "Number",
      "id": 1
    },
    "name": {
      "type": "String",
      "required": false
    }
  }
},
{
  "name": "Order",
  "options": {
    "idInjection": false,
    "foreignKeys": {
      "fk_order_customerId": {
        "name": "fk_order_customerId",
        "entity": "Customer",
        "entityKey": "id",
        "foreignKey": "customerId",
        "onUpdate": "restrict",
        "onDelete": "cascade"
      }
    }
  },
  "properties": {
    "id": {
      "type": "Number"
      "id": 1
    },
    "customerId": {
      "type": "Number"
    },
    "description": {
      "type": "String",
      "required": false
    }
  }
}

boot-script.js

module.exports = function (app) {
  var mysqlDs = app.dataSources.mysqlDS;
  var Book = app.models.Order;
  var Author = app.models.Customer;

  // first autoupdate the `Customer` model to avoid foreign key constraint failure
  mysqlDs.autoupdate('Customer', function (err) {
    if (err) throw err;
    console.log('\nAutoupdated table `Customer`.');

    mysqlDs.autoupdate('Order', function (err) {
      if (err) throw err;
      console.log('\nAutoupdated table `Order`.');
      // at this point the database table `Order` should have one foreign key `customerId` integrated
    });
  });
};

Breaking Changes with GeoPoint since 5.x

Prior to `loopback-connector-mysql@5.x, MySQL connector was saving and loading GeoPoint properties from the MySQL database in reverse. MySQL expects values to bePOINT(X, Y)orPOINT(lng, lat), but the connector was saving them in the opposite order(i.e.POINT(lat,lng)`).

Use the geopoint type to achieve so:

  @property({
    type: 'geopoint'
  })
  name: GeoPoint;

If you have an application with a model that has a GeoPoint property using previous versions of this connector, you can migrate your models using the following programmatic approach:

<summary markdown="span">Click here to expand</summary>

NOTE Please back up the database tables that have your application data before performing any of the steps.

  1. Create a boot script under server/boot/ directory with the following:
'use strict';
module.exports = function (app) {
  function findAndUpdate() {
    var teashop = app.models.teashop;
    //find all instances of the model we'd like to migrate
    teashop.find({}, function (err, teashops) {
      teashops.forEach(function (teashopInstance) {
        //what we fetch back from the db is wrong, so need to revert it here
        var newLocation = {
          lng: teashopInstance.location.lat,
          lat: teashopInstance.location.lng,
        };
        //only update the GeoPoint property for the model
        teashopInstance.updateAttribute('location', newLocation, function (
          err,
          inst,
        ) {
          if (err) console.log('update attribute failed', err);
          else console.log('updateAttribute successful');
        });
      });
    });
  }

  findAndUpdate();
};
  1. Run the boot script by simply running your application or node .

For the above example, the model definition is as follows:

{
  "name": "teashop",
  "base": "PersistedModel",
  "idInjection": true,
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "name": {
      "type": "string",
      "default": "storename"
    },
    "location": {
      "type": "geopoint"
    }
  },
  "validations": [],
  "relations": {},
  "acls": [],
  "methods": {}
}

Running tests

Own instance

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

  • Linux
MYSQL_HOST=<HOST> MYSQL_PORT=<PORT> MYSQL_USER=<USER> MYSQL_PASSWORD=<PASSWORD> MYSQL_DATABASE=<DATABASE> CI=true npm test
  • Windows
SET MYSQL_HOST=<HOST> SET MYSQL_PORT=<PORT> SET MYSQL_USER=<USER> SET MYSQL_PASSWORD=<PASSWORD> SET MYSQL_DATABASE=<DATABASE> SET CI=true npm test

Docker

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

  • Assuming you have Docker installed, run the following script which would spawn a MySQL instance on your local:
source setup.sh <HOST> <PORT> <USER> <PASSWORD> <DATABASE>

where <HOST>, <PORT>, <USER>, <PASSWORD> and <DATABASE> are optional parameters. The default values are localhost, 3306, root, pass and testdb respectively.

  • Run the test:
npm test

changelog

2025-04-14, Version 7.1.2

  • chore: update dependency loopback-datasource-juggler to ^5.1.7 (renovate[bot])

  • chore: update dependency loopback-connector to ^6.2.3 (renovate[bot])

  • chore: update dependency sinon to v20 (renovate[bot])

  • chore: update dependency sinon to ^19.0.5 (renovate[bot])

  • chore: update dependency sinon to ^19.0.4 (renovate[bot])

2025-03-18, Version 7.1.1

  • chore: update dependency loopback-datasource-juggler to ^5.1.6 (renovate[bot])

  • chore: update dependency loopback-connector to ^6.2.2 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^19.8.0 (renovate[bot])

2025-02-12, Version 7.1.0

  • chore: update dependency loopback-datasource-juggler to ^5.1.5 (renovate[bot])

  • chore: update dependency loopback-connector to ^6.2.1 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^19.7.1 (renovate[bot])

  • chore: update dependency loopback-connector to ^6.2.0 (renovate[bot])

  • feat: query to fetch unique columns (Muhammad Aaqil)

  • chore: update dependency mocha to ^11.1.0 (renovate[bot])

  • chore: update dependency debug to ^4.4.0 (renovate[bot])

2024-12-05, Version 7.0.17

  • chore: update dependency loopback-datasource-juggler to ^5.1.3 (renovate[bot])

  • chore: update dependency loopback-connector to ^6.1.12 (renovate[bot])

  • chore: update dependency mocha to v11 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^19.6.0 (renovate[bot])

2024-11-12, Version 7.0.16

  • chore: update dependency loopback-connector to ^6.1.11 (renovate[bot])

  • chore: update dependency loopback-datasource-juggler to ^5.1.2 (renovate[bot])

  • chore: update dependency mocha to ^10.8.2 (renovate[bot])

  • chore: update dependency loopback-connector to ^6.1.10 (renovate[bot])

2024-10-11, Version 7.0.15

  • chore: update dependency loopback-datasource-juggler to ^5.1.1 (renovate[bot])

  • chore: update dependency sinon to v19 (renovate[bot])

  • chore: update dependency ubuntu to v24 (renovate[bot])

  • chore: update dependency eslint to ^8.57.1 (renovate[bot])

  • chore: update dependency sinon to ^18.0.1 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^19.5.0 (renovate[bot])

2024-09-09, Version 7.0.14

  • chore: update dependency loopback-datasource-juggler to ^5.1.0 (renovate[bot])

  • chore: update dependency loopback-connector to ^6.1.9 (renovate[bot])

  • chore: update dependency debug to ^4.3.7 (renovate[bot])

  • fix: enable migration for enum property (Muhammad Aaqil)

  • fix: change condition to treat tinyint as boolean (Muhammad Aaqil)

  • chore: update dependency async to ^3.2.6 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^19.4.1 (renovate[bot])

  • fix: mark primary key auto-increment only if column type is TINYINT SMALLINT MEDIUMINT INT BIGINT (Muhammad Aaqil)

  • chore: update dependency loopback-connector to ^6.1.8 (renovate[bot])

2024-08-12, Version 7.0.13

  • chore: update dependency loopback-datasource-juggler to ^5.0.12 (renovate[bot])

  • chore: update dependency mocha to ^10.7.3 (renovate[bot])

  • chore: update dependency debug to ^4.3.6 (renovate[bot])

  • chore: update dependency mocha to ^10.7.0 (renovate[bot])

2024-07-04, Version 7.0.12

  • chore: update dependency loopback-datasource-juggler to ^5.0.11 (renovate[bot])

  • chore: update dependency loopback-connector to ^6.1.7 (renovate[bot])

  • chore: update dependency mocha to ^10.6.0 (renovate[bot])

  • chore: update dependency mocha to ^10.5.2 (renovate[bot])

  • chore: update dependency loopback-connector to ^6.1.6 (renovate[bot])

2024-06-06, Version 7.0.11

  • chore: update dependency loopback-datasource-juggler to ^5.0.10 (renovate[bot])

  • chore: update dependency debug to ^4.3.5 (renovate[bot])

  • fix: discover properties with json type (Muhammad Aaqil)

  • chore: update dependency sinon to v18 (renovate[bot])

2024-05-15, Version 7.0.10

  • chore: update dependency loopback-datasource-juggler to ^5.0.9 (renovate[bot])

  • chore: update dependency loopback-connector to ^6.1.5 (renovate[bot])

  • chore: update dependency sinon to ^17.0.2 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^19.2.2 (renovate[bot])

  • fix: reading error code (Muhammad Aaqil)

2024-04-08, Version 7.0.9

  • chore: update dependency loopback-connector to ^6.1.4 (renovate[bot])

  • chore: update dependency loopback-datasource-juggler to ^5.0.8 (renovate[bot])

  • chore: update dependency mocha to ^10.4.0 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^19.1.0 (renovate[bot])

2024-03-07, Version 7.0.8

  • chore: update dependency loopback-datasource-juggler to ^5.0.7 (renovate[bot])

  • chore: update dependency loopback-connector to ^6.1.3 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^19.0.3 (renovate[bot])

  • chore: update dependency eslint to ^8.57.0 (renovate[bot])

  • fix: remove extra options to mysql2 pool (Muhammad Aaqil)

  • chore: update dependency @commitlint/config-conventional to v19 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^18.6.2 (renovate[bot])

2024-02-13, Version 7.0.7

  • chore: update dependency loopback-connector to ^6.1.2 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^18.6.1 (renovate[bot])

  • chore: update dependency loopback-datasource-juggler to ^5.0.6 (renovate[bot])

  • chore: update dependency mocha to ^10.3.0 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^18.6.0 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^18.5.0 (renovate[bot])

  • fix: add order by ordinal position for query columns (Muhammad Aaqil)

2024-01-10, Version 7.0.6

  • chore: update dependency loopback-datasource-juggler to ^5.0.5 (renovate[bot])

  • chore: update dependency loopback-connector to ^6.1.1 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^18.4.4 (renovate[bot])

  • chore: update dependency eslint to ^8.56.0 (renovate[bot])

2023-12-07, Version 7.0.5

  • chore: update dependency loopback-datasource-juggler to ^5.0.4 (renovate[bot])

  • chore: update dependency loopback-connector to ^6.1.0 (renovate[bot])

  • chore: update dependency eslint to ^8.55.0 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^18.4.3 (renovate[bot])

  • chore: lock file maintenance (renovate[bot])

  • chore: update dependency sinon to v17 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to v18 (renovate[bot])

  • chore: update dependency eslint to ^8.54.0 (renovate[bot])

  • fix: return enum type (Muhammad Aaqil)

  • ci: hard code db credentials (Rifa Achrinza)

  • chore: drop support for nodejs 16 and lower BREAKING CHANGE: drop support for nodejs 16 and lower (Samarpan Bhattacharya)

  • chore: update dependency loopback-datasource-juggler to v5 (renovate[bot])

  • chore: update dependency loopback-connector to ^6.0.4 (renovate[bot])

  • chore: patch mysql2 package for ensuring special characters in mysql password (Samarpan Bhattacharya)

2023-11-13, Version 7.0.4

  • chore: lock file maintenance (renovate[bot])

  • chore: update dependency loopback-connector to ^6.0.3 (renovate[bot])

  • chore: update dependency sinon to ^16.1.3 (renovate[bot])

  • chore: update dependency mysql2 to ^3.6.3 (renovate[bot])

  • chore: update dependency async to ^3.2.5 (renovate[bot])

  • chore: update dependency eslint to ^8.53.0 (renovate[bot])

  • chore: update dependency eslint to ^8.52.0 (renovate[bot])

  • chore: update actions/setup-node action to v4 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to ^17.8.1 (renovate[bot])

2023-10-16, Version 7.0.3

  • chore: update dependency @commitlint/config-conventional to ^17.8.0 (renovate[bot])

  • chore: update dependency mysql2 to ^3.6.2 (renovate[bot])

  • chore: lock file maintenance (renovate[bot])

  • chore: update dependency eslint to ^8.51.0 (renovate[bot])

  • chore: update dependency sinon to ^16.1.0 (renovate[bot])

  • chore: update dependency eslint to ^8.50.0 (renovate[bot])

  • chore: update dependency sinon to v16 (renovate[bot])

2023-09-11, Version 7.0.2

  • chore: update dependency mysql2 to ^3.6.1 (renovate[bot])

  • chore: update dependency ubuntu to v22 (renovate[bot])

  • chore: lock file maintenance (renovate[bot])

  • chore: update dependency loopback-connector to ^6.0.2 (renovate[bot])

  • chore: update dependency eslint to ^8.49.0 (renovate[bot])

  • chore: update dependency loopback-connector to v6 (renovate[bot])

  • chore: update actions/checkout action to v4 (renovate[bot])

  • chore: update dependency eslint to ^8.48.0 (renovate[bot])

  • chore: update dependency mysql2 to ^3.6.0 (renovate[bot])

  • chore: update dependency sinon to ^9.2.4 (renovate[bot])

  • chore: update dependency loopback-connector to ^5.3.3 (renovate[bot])

  • chore: update dependency mocha to v10 (renovate[bot])

  • chore: update dependency rc to ^1.2.8 (renovate[bot])

  • chore: update dependency mocha to ^8.4.0 (renovate[bot])

  • chore: update dependency eslint to v8 (renovate[bot])

  • chore: update dependency @commitlint/config-conventional to v17 (renovate[bot])

  • chore: update dependency strong-globalize to ^6.0.6 (renovate[bot])

  • chore: update dependency eslint to ^7.32.0 (renovate[bot])

  • chore: update dependency lodash to ^4.17.21 (renovate[bot])

  • chore: update dependency loopback-datasource-juggler to ^4.28.9 (renovate[bot])

2023-08-15, Version 7.0.1

  • chore: update dependency async to ^3.2.4 (renovate[bot])

  • chore: update dependency debug to ^4.3.4 (renovate[bot])

  • chore: add renovate to this repo (dhmlau)

2023-07-11, Version 7.0.0

  • feat: add mysql8 support, update to mysql2 client and drop nodejs v14 and mysql5.7 support (Samarpan Bhattacharya)

  • fix: parse some options to boolean (Muhammad Aaqil)

  • ci: update ci runner (Samarpan Bhattacharya)

2023-01-09, Version 6.2.0

  • feat: add support for multiple insert in one query (Samarpan Bhattacharya)

  • feat: Avoid 'USING ' on FULLTEXT index (FORNO)

  • fix: remove redundant debug (Rifa Achrinza)

  • docs: add SECURITY.md (#465) (Diana Lau)

  • docs: update coc (#464) (Diana Lau)

  • docs: add code of conduct (#463) (Diana Lau)

  • chore: remove .travis.yml (Diana Lau)

  • chore: add @marioestradarosa as codeowners (Diana Lau)

2021-10-20, Version 6.1.0

  • feat(operators): add match against operator (Akshat Dubey)

2021-07-12, Version 6.0.2

  • chore: move this repo to loopbackio org (Diana Lau)

  • ci: add GitHub Actions (Diana Lau)

2021-06-10, Version 6.0.1

  • fix (core) accepts boolean type (yongzhi-chen)

  • fix(docs): Specify table creation order method (Roderik van Heijst)

  • fix(docs): update enum type (Diana Lau)

2020-09-01, Version 6.0.0

  • remove bluebird from devDependencies (Miroslav Bajtoš)

  • update eslint + config to latest (Miroslav Bajtoš)

  • update mocha to 8.x (Miroslav Bajtoš)

  • chore: update dependencies to latest (Miroslav Bajtoš)

  • [SEMVER-MAJOR] Drop support for Node.js 8.x (Miroslav Bajtoš)

  • chore: switch to DCO (Diana Lau)

  • docs: update default value setup section (Agnes Lin)

  • chore: add Node.js 14 to travis (Diana Lau)

  • chore: update CODEOWNERS (Diana Lau)

  • fixed typo on readme (filipef101)

2020-07-10, Version 5.4.4

  • docs: update README with lb4 style (Agnes Lin)

  • chore: update strong-globalize (Diana Lau)

  • fix MySQL README layout (Agnes Lin)

2020-03-19, Version 5.4.3

  • Exclude 'deps' and '.github' from npm publish (Dominique Emond)

  • fix README display on the site (Agnes Lin)

  • chore: update copyrights year (Diana Lau)

  • chore: improve issue and PR templates (Nora)

  • chore: move mocha flag to opts (jannyHou)

  • fix: tests for datatypes (jannyHou)

  • fix: force exit (jannyHou)

  • update tests (jannyHou)

  • upgrade dependencies (jannyHou)

2019-07-25, Version 5.4.2

  • chore: add node 12 (jannyHou)

  • feat: run shared tests (jannyHou)

2019-05-28, Version 5.4.1

  • fix: allow DataSource to reconnect properly (Antonio Trapani)

  • update Travis MySQL config (Agnes Lin)

  • fix: update lodash (jannyHou)

  • chore: update copyrights years (Agnes Lin)

2019-05-07, Version 5.4.0

  • Fix bug property declared index being recreate (HugoPoi)

  • Add onDelete onUpdate foreign key config options (HugoPoi)

  • Fix bug foreign key index being delete wrongly (HugoPoi)

  • chore: update travis and CODEOWNERS (Diana Lau)

2018-09-12, Version 5.3.1

  • update strong-globalize version (Diana Lau)

2018-07-12, Version 5.3.0

  • upgrade deps (Raymond Feng)

  • pin mysql image to 5.7 (Raymond Feng)

  • use "owner" for discovered results (Raymond Feng)

  • chore: update license (Diana Lau)

2017-10-17, Version 5.2.0

  • revert mocha version change (Diana Lau)

  • update dependencies (Diana Lau)

  • update globalize string (Diana Lau)

  • Add stalebot configuration (Kevin Delisle)

2017-08-21, Version 5.1.0

  • Create Issue and PR Templates (#322) (Sakib Hasan)

  • Use MySQL DEFAULT Clause/Constant (#319) (Eric Dowell)

  • Remove unnecessary line causing validation fail (ssh24)

  • isNewInstance undefined for after save hook (biniam)

  • Add datatype flags to README (biniam)

  • upgrade eslint deps (biniam)

  • Add CODEOWNER file (Diana Lau)

2017-07-10, Version 5.0.0

  • Add DECIMAL to Number prop type (Tetsuo Seto)

  • Fix fk docs to avoid constraint errors (ssh24)

  • Document GeoPoint migration (biniam)

  • Honor user specified datatype on PKs (ssh24)

  • Require init on mocha args (ssh24)

  • Add docs on FK integrity (ssh24)

  • Create database on the docker script (ssh24)

  • Handle null vals properly (biniam)

  • Allow case sensitive regex operation (ssh24)

  • switch long and lat for geopoint type (biniam)

  • discovery.test: fix discoverModels tests (Kevin Delisle)

2017-06-01, Version 4.1.1

  • Add http status code translations for errors (Kevin Delisle)

  • Allow explicit data types (ssh24)

  • Revert "switch long and lat for geopoint type" (biniam)

  • switch long and lat for geopoint type (biniam)

  • Escape index names (#280) (Sakib Hasan)

  • Fix docker setup (#279) (Sakib Hasan)

  • Add docker setup (#278) (Sakib Hasan)

  • Adding support for fractional seconds. (Joost de Bruijn)

  • fix compare of foreign keys for autoupdate (#272) (Sergey Nosenko)

  • Update README.md (Antoine LA)

2017-05-02, Version 4.1.0

  • Tests for datetime types (Kevin Delisle)

  • Add new type DateString to fromColumnValue (Buck Bito)

  • Remove String manipulations of Date objects (Buck Bito)

  • Properties with mysql custom "columnName" don't get autoupdated (#273) (Sergey Nosenko)

  • Revert PR #257 (#266) (Sakib Hasan)

  • Fix async.each in migration (#262) (Benjamin Schuster-Boeckler)

  • refactor date, timestamp and datetime data types handling (#257) (Sergey Nosenko)

  • Fix too many connection error (#261) (Sakib Hasan)

2017-03-31, Version 4.0.0

  • Replicate new issue_template from loopback (Siddhi Pai)

  • Replicate issue_template from loopback repo (Siddhi Pai)

  • fix linting problems (juanra)

  • Extract functions to base connector (ssh24)

  • Refactor alter table (ssh24)

  • Typo on README (#236) (Ctibor Laky)

  • Return if column is generated or not (#198) (Christiaan Westerbeek)

  • Upgrade to loopback-connector@4.x (Loay)

  • Refactor migration methods (ssh24)

  • Refactor Discovery Methods (Loay)

  • Remove old TODO and commented out code (Matthew Dickinson)

  • Fix autoupdate to create foreign keys after tables (Matthew Dickinson)

  • Add logging for errors encountered in discovery (Matthew Dickinson)

  • Update signature for alterTable (Matthew Dickinson)

  • Limit foreign key creation current connector (Matthew Dickinson)

  • Fix linting error (Matthew Dickinson)

  • Added test to validate foreign key handling (Matthew Dickinson)

  • Update foreign key creation table name handling (Matthew Dickinson)

  • Update alterTable to actually drop constraints (Matthew Dickinson)

  • Add rough handling for automatic foreign keys (Matthew Dickinson)

  • remove line not needed (#237) (ivy ho)

  • Update LB-connector version (Loay)

2017-01-13, Version 3.0.0

  • Follow mysql recommendations for handling booleans (Carl Fürstenberg)

  • Fix readme glitch (#231) (Rand McKinney)

  • Update readme w info from docs (#229) (Rand McKinney)

  • Fix expected column name when autoupdate (muhammad hasan)

  • Update paid support URL (Siddhi Pai)

  • Fix CI Failures (Loay Gewily)

  • Drop support for Node v0.10 and v0.12 (Siddhi Pai)

  • Start the development of the next major version (Siddhi Pai)

  • Update README with correct doc links, etc (Amir Jafarian)

2016-10-17, Version 2.4.0

  • Add connectorCapabilities global object (#201) (Nicholas Duffy)

  • Remove unused prefix for test env vars (#203) (Simon Ho)

  • Update translation files - round#2 (#199) (Candy)

  • Add CI fixes (#197) (Loay)

  • Add translated files (gunjpan)

  • Update deps to loopback 3.0.0 RC (Miroslav Bajtoš)

  • Remove Makefile in favour of NPM test scripts (Simon Ho)

  • Fixing lint errors (Ron Lloyd)

  • Autoupdate mysql.columnName bug fix (Ron Lloyd)

  • Tests for autoupdate mysql.columnName bug fix (Ron Lloyd)

  • Use juggler@3 for running the tests (Miroslav Bajtoš)

  • Explictly set forceId:false in test model (Miroslav Bajtoš)

  • Fix pretest and init test configs (Simon Ho)

  • Fix to configure model index in keys field (deepakrkris)

  • Update eslint infrastructure (Loay)

  • test: use dump of original test DB as seed (Ryan Graham)

  • test: skip cardinality, update sub_part (Ryan Graham)

  • test: accept alternate test db credentials (Ryan Graham)

  • test: use should for easier debugging (Ryan Graham)

  • test: account for mysql version differences (Ryan Graham)

  • test: match case with example/table.sql (Ryan Graham)

  • test: separate assertions from test flow control (Ryan Graham)

  • test: update tests to use example DB (Ryan Graham)

  • test: seed test DB with example (Ryan Graham)

  • test: fix undefined password (Ryan Graham)

  • Add special handling of zero date/time entries (Carl Fürstenberg)

  • Add globalization (Candy)

  • Update URLs in CONTRIBUTING.md (#176) (Ryan Graham)

2016-06-21, Version 2.3.0

  • Add function connect (juehou)

  • insert/update copyright notices (Ryan Graham)

  • relicense as MIT only (Ryan Graham)

  • Override other settings if url provided (juehou)

  • Add connectorCapabilities (Amir Jafarian)

  • Implement ReplaceOrCreate (Amir Jafarian)

2016-02-19, Version 2.2.1

  • Remove sl-blip from dependencies (Miroslav Bajtoš)

  • Upgrade should module (Amir Jafarian)

  • removed console.log (cgole)

  • seperate env variable for test db (cgole)

  • Changed username to user (cgole)

  • Added db username password (cgole)

  • Add mysql CI host (cgole)

  • Refer to licenses with a link (Sam Roberts)

  • Pass options to the execute command. (Diogo Correia)

  • Use strongloop conventions for licensing (Sam Roberts)

2015-07-30, Version 2.2.0

  • Clean up regexop tests (Simon Ho)

  • Add regexp operator tests (Simon Ho)

  • Fix RegExp unit test setup/teardown (Simon Ho)

  • Add support for RegExp operator (Simon Ho)

2015-05-29, Version 2.1.1

  • Fix the failing tests (Raymond Feng)

2015-05-18, Version 2.1.0

  • Update deps (Raymond Feng)

  • Start to add transaction support (Raymond Feng)

2015-05-14, Version 2.0.1

  • Fix the typo (Raymond Feng)

2015-05-13, Version 2.0.0

  • Update deps (Raymond Feng)

  • Refactor the code to use base SqlConnector (Raymond Feng)

2015-04-02, Version 1.7.0

  • Return isNewInstance from upsert (Raymond Feng)

  • Update rc dep (Raymond Feng)

  • Return count when updating or deleting models (Simon Ho)

  • Update README.md (Simon Ho)

  • Add test running instructions to readme (Simon Ho)

  • Fix mysql neq for NULL value. (ulion)

  • replace dataLength instead of adding length property (Partap Davis)

  • Allow models backed by MySQL to reference mongodb ObjectID (Raymond Feng)

  • Query string length for schema in characters in addition to bytes (Partap Davis)

2015-02-20, Version 1.6.0

  • Update deps (Raymond Feng)

  • Include tests of persistence hooks from juggler. (Miroslav Bajtoš)

2015-01-15, Version 1.5.1

  • Fix the loop of models (Raymond Feng)

  • Set ok default to false (Geoffroy Lesage)

  • Fixed missing 'ok' (Geoffroy Lesage)

  • Changed default type mapping (Geoffroy Lesage)

  • Fixed isActual syntax to accept optional model arg (Geoffroy Lesage)

  • Fixed isActual implemenation (Geoffroy Lesage)

  • Inherit Schema From DataSource if not defined (Serkan Serttop)

2015-01-09, Version 1.5.0

  • Use mysql.escape/escapeId() (Raymond Feng)

  • Fix bad CLA URL in CONTRIBUTING.md (Ryan Graham)

  • (cherry picked from commit a6d31e8) (yogesh)

2014-12-05, Version 1.4.9

  • Add a test case for autoupdate (Raymond Feng)

  • Create 'NOT NULL' constraint for required or id properties (Raymond Feng)

  • Better handle discovery of nullable columns (Raymond Feng)

2014-11-27, Version 1.4.8

  • fix(initialization): bug fix for setting limit on number of connections in connection pool (cpentra1)

  • Add contribution guidelines (Ryan Graham)

2014-09-11, Version 1.4.7

  • Enhance error reporting for automigrate/autoupdate (Raymond Feng)

2014-09-10, Version 1.4.6

  • Bump version (Raymond Feng)

  • Use table name instead of model name (Raymond Feng)

  • Use async and make sure errors are passed to callback (Raymond Feng)

2014-08-25, Version 1.4.5

  • Bump version (Raymond Feng)

  • Make sure the deferred query will be invoked only once (Raymond Feng)

2014-08-20, Version 1.4.4

  • Bump version (Raymond Feng)

  • Add ping() (Raymond Feng)

2014-08-20, Version 1.4.3

  • Bump version (Raymond Feng)

  • Fix MySQL conversion for embedded model instance (Raymond Feng)

  • Fix the createDatabase option (Raymond Feng)

2014-08-15, Version 1.4.2

  • Bump version (Raymond Feng)

  • Allow properties to pass through mysql driver (Raymond Feng)

  • Fix the default length for strings to avoid row size overflow (Raymond Feng)

2014-06-27, Version 1.4.1

  • Bump version (Raymond Feng)

  • Fix the test cases as now inq/nin is checked for array values (Raymond Feng)

  • Update link to doc (Rand McKinney)

2014-06-23, Version 1.4.0

  • Bump version (Raymond Feng)

  • cannot read property of undefined fixed (Johnny Bill)

  • Fix comparison for null and boolean values (Raymond Feng)

  • Map object/json to TEXT (Raymond Feng)

2014-06-04, Version 1.3.0

  • Remove peer dependency on datasource-juggler (Miroslav Bajtoš)

2014-06-02, Version 1.2.3

  • Bump version (Raymond Feng)

  • Fix sql injection and add test cases (Raymond Feng)

2014-05-29, Version 1.2.2

  • Bump version (Raymond Feng)

  • Fix the varchar length (Raymond Feng)

  • Add like/nlike support (Raymond Feng)

  • Fix object/json type mapping (Raymond Feng)

2014-05-16, Version 1.2.1

  • Bump versions (Raymond Feng)

  • Fix buildWhere (Raymond Feng)

  • Add support for logical operators (AND/OR) (Raymond Feng)

  • updateOrCreate assumes numeric primary key(s) (Scott Anderson)

2014-04-08, Version 1.2.0

  • Bump version (Raymond Feng)

  • Remove the commented out code (Raymond Feng)

  • Fix the query for discovery with current user (Raymond Feng)

  • Fix the table generation for string ids (Raymond Feng)

  • Update deps (Raymond Feng)

  • Use NULL for undefined (Raymond Feng)

  • Prevent inserting undefined values (Marat Dyatko)

  • Update to dual MIT/StrongLoop license (Raymond Feng)

  • Fix merge issue (Raymond Feng)

  • Reformat code (Raymond Feng)

  • Update discovery.js (Samer Aldefai)

  • Fix link to docs. (Rand McKinney)

  • Replaced most content with link to docs. (Rand McKinney)

  • Move mocha args to test/mocha.opts (Ryan Graham)

  • Make 'npm test' more useful to CI (Ryan Graham)

  • Prevent extra files from going into npm (Ryan Graham)

2013-12-06, Version 1.1.1

  • Bump version (Raymond Feng)

  • Update deps (Raymond Feng)

  • Add the test for loopback-datasource-juggler PR-48 (Raymond Feng)

  • Fix the orderBy (Raymond Feng)

2013-11-27, Version 1.1.0

  • Bump version (Raymond Feng)

  • Refactor the runQuery logic into a function (Raymond Feng)

  • Improve the connector based on review feedbacks (Raymond Feng)

  • Allow connectionLmit to be set (Raymond Feng)

  • Use connection pool for MySQL (Raymond Feng)

  • Update docs.json (Rand McKinney)

  • Fix the regression caused by juggler (Raymond Feng)

2013-11-20, Version 1.0.2

  • Remove blanket (Raymond Feng)

  • Bump version and update deps (Raymond Feng)

  • Append error to the message (Raymond Feng)

  • Add NOTICE and update READE (Raymond Feng)

  • Update README.md (Rand McKinney)

  • Update the internal github dependency (Raymond Feng)

2013-10-28, Version 1.0.0

  • First release!