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

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

Open
henrikekblad opened this issue Dec 23, 2019 · 1 comment
Open

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

henrikekblad opened this issue Dec 23, 2019 · 1 comment

Comments

@henrikekblad
Copy link

henrikekblad commented Dec 23, 2019

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?

@henrikekblad
Copy link
Author

Fixed in #15

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant