I would like to read an image file into a MongoDB document's binary field from mongo shell. I can do this in Java with MongoDB Java driver. However, I would like to be able to do with a mongo script from mongo shell. Is this possible?
For example, I would like to do this:
D:\mongo\bin> mongo --shell myscript.js
where myscript.js is as follow:
conn = new Mongo();
db = conn.getDB("mydb");
db.mycoll.remove();
db.mycoll.insert( { name : "LCD monitor",
thumbnail : Binary(0, **cat("D:\\images\\lcdmonitor.jpg")**)
} );
As is, the use of cat() method gives "InternalError: buffer too small (anon):1", as cat() is for reading text file only.
Which method / function in place of cat() should I use to make this work? Can this be done in the mongo shell at all?