mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-03 19:36:20 +00:00 
			
		
		
		
	Handle default values with Bookshelf
This commit is contained in:
		
							parent
							
								
									cc6db73e33
								
							
						
					
					
						commit
						057d62b9f9
					
				@ -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;
 | 
			
		||||
 | 
			
		||||
@ -55,4 +55,4 @@
 | 
			
		||||
    "npm": ">= 5.3.0"
 | 
			
		||||
  },
 | 
			
		||||
  "license": "MIT"
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -46,4 +46,4 @@
 | 
			
		||||
    "npm": ">= 5.0.0"
 | 
			
		||||
  },
 | 
			
		||||
  "license": "MIT"
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user