mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 11:25:17 +00:00
Merge pull request #3744 from strapi/feature/mysqlUUID
Add support for bookshelf plugin loading
This commit is contained in:
commit
3b32b78d78
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user