fix the bug for 64bit type

This commit is contained in:
Sukchan Lee 2017-08-28 09:59:40 +09:00
parent 6e60d3213e
commit 07da98ae89
3 changed files with 23 additions and 1 deletions

View File

@ -42,7 +42,8 @@
"redux": "^3.6.0",
"redux-actions": "^2.0.3",
"redux-saga": "^0.15.3",
"styled-components": "2.0.0-19"
"styled-components": "2.0.0-19",
"traverse": "^0.6.6"
},
"scripts": {
"dev": "node server/index.js",

View File

@ -11,6 +11,8 @@ import * as Notification from 'modules/notification/actions';
import { Subscriber } from 'components';
import traverse from 'traverse';
const formData = {
"security": {
k: "465B5CE8 B199B49F AA5F0A2E E238A6BC",
@ -67,6 +69,21 @@ class Document extends Component {
if (this.props.visible === false && nextProps.visible === true) {
if (subscriber.data) {
// Mongoose library has a problem for 64bit-long type
//
// FETCH : the library returns 'Number' type for 64bit-long type
// CREATE/UPDATE : the library returns 'String' type for 64bit-long type
//
// In this case, I cannot avoid json-schema validation function
// So, I've changed the type from 'String' to 'Number' if the key name is 'downlink' and 'uplink'
//
// The followings are changed from 'String' to 'Number' after DB CREATE or UPDATE
// - ambr.downlink, ambr.uplink, qos.mbr.downlink, qos.mbr.uplink, qos.gbr.downlink, qos.gbr.uplink
//
traverse(subscriber.data).forEach(function(x) {
if (this.key == 'downlink') this.update(Number(x));
if (this.key == 'uplink') this.update(Number(x));
})
this.setState({ formData: subscriber.data })
} else {
this.setState({ formData });

View File

@ -3736,6 +3736,10 @@ tough-cookie@~2.3.0:
dependencies:
punycode "^1.4.1"
traverse@^0.6.6:
version "0.6.6"
resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.6.tgz#cbdf560fd7b9af632502fed40f918c157ea97137"
trim-right@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"