I'm developping a little utlity tool which parse some files, extracts a specific information and then store it into a mongodb collection.
It's working right now, but it's doing something like :
#!/bin/bash
find myFolder | while read f
do
# some things
...
# and then
echo "db.test.insert({'val': BinData(0, '$data')});" | mongo -quiet --host 127.0.0.1:36427 collectionName
done
But the "problem" here is that I'm opening / closing the mongodb connection everytime.
So here is the question:
Is there a way to start the mongodb connection, and then happen some data into it.
I KNOW that the following code is totally wrong, but it's just to give you an example of the kind of feature I'm looking for :
#!/bin/bash
mongoConn=`mongo 127.0.0.1:36427 collectionName`
find myFolder | while read f
# ...
echo "db.test.insert(..);" > mongoConn
done
echo "exit;" > mongoConn