diff --git a/packages/strapi-bookshelf/lib/index.js b/packages/strapi-bookshelf/lib/index.js index 99c8d984c0..72e76213be 100755 --- a/packages/strapi-bookshelf/lib/index.js +++ b/packages/strapi-bookshelf/lib/index.js @@ -89,9 +89,16 @@ module.exports = function(strapi) { tableName: definition.collectionName, hasTimestamps: _.get(definition, 'options.timestamps') === true, idAttribute: _.get(definition, 'options.idAttribute', 'id'), - associations: [] - }, definition.options); + associations: [], + defaults: Object.keys(definition.attributes).reduce((acc, current) => { + if (definition.attributes[current].type && definition.attributes[current].default) { + acc[current] = definition.attributes[current].default; + } + return acc; + }, {}) + }, definition.options); + if (_.isString(_.get(connection, 'options.pivot_prefix'))) { loadedModel.toJSON = function(options = {}) { const { shallow = false, omitPivot = false } = options; diff --git a/packages/strapi-bookshelf/package.json b/packages/strapi-bookshelf/package.json index 055b12c625..cd4b1b9473 100755 --- a/packages/strapi-bookshelf/package.json +++ b/packages/strapi-bookshelf/package.json @@ -55,4 +55,4 @@ "npm": ">= 5.3.0" }, "license": "MIT" -} \ No newline at end of file +} diff --git a/packages/strapi-knex/package.json b/packages/strapi-knex/package.json index be44035ed6..c650cd122f 100755 --- a/packages/strapi-knex/package.json +++ b/packages/strapi-knex/package.json @@ -46,4 +46,4 @@ "npm": ">= 5.0.0" }, "license": "MIT" -} \ No newline at end of file +}