One Star

MongoDB and Multi-Inserts using tMongoDBOutput

In the mongo shell, I can perform a multi-insert by passing an array of json documents to the insert method on a collection, like so:
db.foo.insert()

How can I do the same thing with a tMongoDBOutput? I am not going to iterate through a list of documents and update them one by one. I would also not want to write to a temp file and then use tMongDBBulkLoad.
I've found a current workaround with the following:


And in my tMongoDBRow:

Oddly enough, I am constructing a String representation of a JSONArray, and the tMongoDBRow appears to be converting it into an actualy JSONArray. If I issued the same command in the Mongo console, it would fail with a "...attempted to save a string value.  document expected. at src/mongo/shell/collection.js:140".

How can I do this using a tMongoDBRow?
Thank you.
1 REPLY
Community Manager

Re: MongoDB and Multi-Inserts using tMongoDBOutput

Try this expression on tMongoDBRow:
"db.foo.insert()"

Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business