I’m trying to parse a very large chunk of data into a new MongoDB database and when I run the job I keep getting an error when I do db.myCollection.find().
The error is error: non ascii character detected.
I am using Node.js and Mongoose to populate the database. The only characters I have seen that might be causing problems are ', , and - but I have done a .replace on all of them. I tried escaping them (\) and I tried just removing them entirely and nothing seems to be working.
My biggest problem is that I don’t get any errors when I am saving the objects, I just get that message when I try to view the collection.
Is there any information out there on sanitizing MongoDB input?
If it’s string data then maybe make sure it’s encoded as UTF8 before inserting. Most drivers should check this, but it could’ve been overlooked in the Mongoose driver. All strings in MongoDB are stored as UTF8, as defined by the BSON spec.