Closed straccio closed 7 years ago
This is caused because my Particle Device have variables with a dot in a name.
Wow... nice catch.
I assume this worked with the Public cloud?
@AntonPuko - I think we just need to save vars/functions as serialized json
Yes it's work.... serializing can impact performance.... but is the solution. How can i test mongo db? i miss the configuration part.
Serializing won't affect performance in this case -- it would be a huge micro-optimization.
Mongodb will also fail here. It doesn't support having .
in property names. - https://github.com/louischatriot/nedb/issues/399
but it's not a "property", o better, a field. is a field type Object that need to be serialized on db site.
No, when it gets saved as an object in the DB, it looks like it has properties with dots in them to NEDB.
Here is the type for device attributes:
export type DeviceAttributes = {
appHash: ?string,
currentBuildTarget: string,
deviceID: string,
functions?: ?Array<string>,
imei?: string,
ip: string,
isCellular: boolean,
last_iccid?: string,
lastFlashedAppName: ?string,
lastHeard: Date,
name: string,
ownerID: ?string,
particleProductId: number,
productFirmwareVersion: number,
registrar: string,
timestamp: Date,
variables?: ?Object,
};
variables
will be stored as something like this:
type Variable = {[key: string]: string};
// data is
{'test.Var': 'INT'},
This will break NEDB/Mongo.
This can help! https://lodash.com/docs#toPairs
I was thinking JSON.toString
or Object.entries
Ok, I'll make the change. But @straccio what is the idea behind name variables with dots? .
is an operator almost in every language.
I use a dot as separator. <characteristic type %03d >-<accessory id %02d >.<characteristic id %02d> Its not a problem replace the dot with something else.
On the program side i don't have any dots or numbers for variables i have something like humidity, or temperature.
I think that is cause because DeviceAtributes.variables is an Object Type.
`[2017-07-07T10:40:48.890Z] ERROR: Device.js/31122 on localhost: Device disconnected (disconnectCounter=1) logInfo: { "cache_key": "_8", "deviceID": "383433383335353334373931", "duration": 0.058 }