Merge branch 'master' into improve/doc-plugin

This commit is contained in:
Aurélien GEORGET 2018-01-10 13:10:04 +01:00 committed by GitHub
commit f5512c8e4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 12 deletions

View File

@ -44,13 +44,9 @@ module.exports = function (strapi) {
// Connect to mongo database
if (_.isEmpty(username) || _.isEmpty(password)) {
instance.connect(`mongodb://${host}:${port}/${database}`, {
useMongoClient: true
});
instance.connect(`mongodb://${host}:${port}/${database}`);
} else {
instance.connect(`mongodb://${username}:${password}@${host}:${port}/${database}`, {
useMongoClient: true
});
instance.connect(`mongodb://${username}:${password}@${host}:${port}/${database}`);
}
// Handle error

View File

@ -5,11 +5,14 @@
*/
module.exports = mongoose => {
require('mongoose-double')(mongoose);
require('mongoose-float').loadType(mongoose);
const SchemaTypes = mongoose.Schema.Types;
SchemaTypes.Decimal.prototype.cast = function (value) {
return value.toString();
};
return {
convertType: mongooseType => {
switch (mongooseType.toLowerCase()) {
@ -22,9 +25,9 @@ module.exports = mongoose => {
case 'biginteger':
return 'Number';
case 'float':
return SchemaTypes.Float;
return 'Float';
case 'decimal':
return SchemaTypes.Double;
return 'Decimal';
case 'date':
case 'time':
case 'datetime':

View File

@ -16,8 +16,7 @@
"main": "./lib",
"dependencies": {
"lodash": "^4.17.4",
"mongoose": "^4.11.10",
"mongoose-double": "0.0.1",
"mongoose": "^5.0.0-rc1",
"mongoose-float": "^1.0.2",
"pluralize": "^6.0.0",
"strapi-utils": "3.0.0-alpha.7.3"

View File

@ -159,7 +159,7 @@ export class Edit extends React.Component {
if (isObject(e.target.value) && e.target.value._isAMomentObject === true) {
formattedValue = moment(e.target.value, 'YYYY-MM-DD HH:mm:ss').format();
} else if (['float', 'integer', 'bigint'].indexOf(currentSchema.fields[e.target.name].type) !== -1) {
} else if (['float', 'integer', 'biginteger', 'decimal'].indexOf(currentSchema.fields[e.target.name].type) !== -1) {
formattedValue = toNumber(e.target.value);
}