I want to write a script using javascript to insert a binary file into the mongodb. The file is far less than the max 16MB limit, so implementing this with GridFS is beyond the scope of the feature I'm writing.
I'm writing the script so I can run it like so:
mongo localhost:27017/myMongoDB loadMyFile.js
loadMyFile.js
looks something like this:
db.myCollection.insert( {
fileName: "myFile.ogg",
file: cat(./myFile.ogg")
});
But when I search the collection:
db.myCollection.find({
fileName:"myFile.ogg"
});
I get something like:
{
"_id":ObjectId("53d2d6c76c694a37315c0195"),
"fileName": "myFile.ogg",
"file":"ID3\u0002"
}
Which seems wrong. Please assist. Thanks in advanced.