Hi guys,I need help to get information through the mongo query, but this information is inside a serialized java object.
My object have this content:
"details" : { "details" : "{ \"batteryLvl\": \"85\", \"operation\": \"DEVICE_STATUS_BATTERY\", \"doorSerial\": \"TLKJ3ACT53UTZTNW\", \"logInstant\": \"1682531305560\", \"class\": \"br.com.loopkey.model.logging.CommBatteryLoggingModel\" }"
I’m trying to convert this information into a string in several ways, using toString, or convert but I’m not succeeding. Because from there I would break information that I need.
When I try to convert using toString function:
> db.logs.aggregate([ { $match: { $and: [ { "doorId": 12804 }, { "operation": 130 } ] } }, { "$project": { "doorId": "$doorId", "details": "$details","teste":{$toString: "$details"}} }])
2023-04-27T00:59:03.603+0000 E QUERY [js] Error: command failed: {
"ok" : 0,
"errmsg" : "Unsupported conversion from object to string in $convert with no onError value",
"code" : 241,
"codeName" : "ConversionFailure"
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:18:14
_assertCommandWorked@src/mongo/shell/assert.js:536:17
assert.commandWorked@src/mongo/shell/assert.js:620:16
DB.prototype._runAggregate@src/mongo/shell/db.js:260:9
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1062:12
@(shell):1:1
The version of mongo is 4.0.6. At first I have no way to update this mongo, so I would like to know if there is any way I can force this conversion to be able to treat it as a string?