mirror of
https://github.com/strapi/strapi.git
synced 2025-09-06 23:28:02 +00:00
Use Decimal for mongo and mongoose
Use Decimal128 mongo's type instead mongoose-double package. Mongodb will be store decimal values as NumberDecimal, not as string.
This commit is contained in:
parent
7c3aaf691b
commit
e48b10c98e
@ -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':
|
||||
|
@ -17,7 +17,6 @@
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.4",
|
||||
"mongoose": "^4.11.10",
|
||||
"mongoose-double": "0.0.1",
|
||||
"mongoose-float": "^1.0.2",
|
||||
"pluralize": "^6.0.0",
|
||||
"strapi-utils": "3.0.0-alpha.7.2"
|
||||
|
Loading…
x
Reference in New Issue
Block a user