Skip to content
This repository was archived by the owner on Jul 23, 2020. It is now read-only.
This repository was archived by the owner on Jul 23, 2020. It is now read-only.

Cannot apply $inc to a value of non-numeric type #16

@henrikekblad

Description

@henrikekblad

After migrating my redis db to mongo it seems the nodebb expects quite a few fields as numbers (not strings).

I.e. "global" _key looks like this:

{ "_id" : ObjectId("5dffcc527842867f4963185c"), 
"nextUid" : "9474", "userCount" : "8970", "nextCid" : "44", "nextTid" : "10847", "topicCount" : "9698",
 "nextPid" : "102899", "postCount" : "101416", "nextNid" : "9661", "nextMid" : "39784", "nextEid" : "6975", "uniqueIPCount" : "2376774", "nextChatRoomId" : "1697", "nextPollId" : "5", "nextFlagId" :
 "34", "_key" : "global" }

When the nodebb forum fetches a new id it uses the $inc fuction which results in an error:

[analytics] Encountered error while writing analytics to data store MongoError: Cannot apply $inc to a value of non-numeric type. {_id: ObjectId('5dffcc527842867f4963185c')} 
has the field 'uniqueIPCount' of non-numeric type string

Any idea how should we know which field values should to be converted into numbers? Or do we have to manually rewrite config? In that case, could other objects also have this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions