I'm trying to populate my MongoDB with sample data to run a performance test. My documents are meant to have a datetime
field named last_update
which I believe is self describing.
In order to have conclusive results I need a lot of documents (starting from 1M going to 1G). That's why I decided to use a tool like mongoimport
to populate my collection.
Here's a line from my json
file that I'm feeding to mongoimport
:
{ "counter" : 0, "last_update" : new Date() }
I'm expecting each document to have the current datetime
as it is saved into collection. But mongoimport
exits with an error:
exception:BSON representation of supplied JSON is too large: code FailedToParse: FailedToParse: Expecting '}' or ',': offset:42
It seems mongoimport
has a problem with new Date()
statement. So my question is how can I add bulk number of documents into a collection with a field set to current time?
"The mongoimport tool provides a route to import content from a JSON, CSV, or TSV export created by mongoexport, or potentially, another third-party export tool." Hence i think u cannot use new Date();
in the json file. Try to insert data by using a javascript file.
db.collection.insert({ "counter" : 0, "last_update" : new Date() });
then use command 127.0.0.1/db new.js
Otherwise u should give the datestring in the json to insert docs using mongoimport