diff --git a/docs/3.0.0-beta.x/configurations/configurations.md b/docs/3.0.0-beta.x/configurations/configurations.md index e0c62c8e82..3a614b05d4 100644 --- a/docs/3.0.0-beta.x/configurations/configurations.md +++ b/docs/3.0.0-beta.x/configurations/configurations.md @@ -147,6 +147,18 @@ module.exports = (mongoose, connection) => { }; ``` +Another example would be using the `bookshelf-uuid` plugin for MySQL, you can register it like this: + +**Path —** `./config/functions/bookshelf.js`. + +```js +'use strict'; + +module.exports = (bookshelf, connection) => { + bookshelf.plugin(require('bookshelf-uuid')); +}; +``` + --- ## Locales diff --git a/docs/3.0.0-beta.x/guides/models.md b/docs/3.0.0-beta.x/guides/models.md index afd04f3a31..74fadf6113 100644 --- a/docs/3.0.0-beta.x/guides/models.md +++ b/docs/3.0.0-beta.x/guides/models.md @@ -34,6 +34,7 @@ The options key on the model-json states. - `idAttribute`: This tells the model which attribute to expect as the unique identifier for each database row (typically an auto-incrementing primary key named 'id'). _Only valid for strapi-hook-bookshelf_ - `idAttributeType`: Data type of `idAttribute`, accepted list of value below. _Only valid for strapi-hook-bookshelf_ - `timestamps`: This tells the model which attributes to use for timestamps. Accepts either `boolean` or `Array` of strings where first element is create data and second element is update date. Default value when set to `true` for Bookshelf is `["created_at", "updated_at"]` and for MongoDB is `["createdAt", "updatedAt"]`. +- `uuid` : Boolean to enable UUID support on MySQL, you will need to set the `idAttributeType` to `uuid` as well and install the `bookshelf-uuid` package. To load the package you can see [this example](../configurations/configurations.md#bookshelf-mongoose). ## Define the attributes diff --git a/packages/strapi-hook-bookshelf/lib/mount-models.js b/packages/strapi-hook-bookshelf/lib/mount-models.js index 1f6bba0797..11bea5bc70 100644 --- a/packages/strapi-hook-bookshelf/lib/mount-models.js +++ b/packages/strapi-hook-bookshelf/lib/mount-models.js @@ -692,6 +692,9 @@ module.exports = ({ models, target, plugin = false }, ctx) => { // Initialize lifecycle callbacks. loadedModel.initialize = function() { + // Load bookshelf plugin arguments from model options + this.constructor.__super__.initialize.apply(this, arguments); + const lifecycle = { creating: 'beforeCreate', created: 'afterCreate',