summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-02-02 09:28:43 -0500
committerEliot Horowitz <eliot@10gen.com>2009-02-02 09:28:43 -0500
commitff7573c65af86445e64eea657baeed6720e4d238 (patch)
tree304eab9bf4fba23822dfc8ec09a7c825519ff552 /tools
parentc8acc4ac0a0d6dba77435768fbc61cc40f55e8c9 (diff)
downloadmongo-ff7573c65af86445e64eea657baeed6720e4d238.tar.gz
option for creating an index before or ater import
Diffstat (limited to 'tools')
-rw-r--r--tools/importJSON.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/importJSON.cpp b/tools/importJSON.cpp
index d9b3e171cf6..dff49a890bd 100644
--- a/tools/importJSON.cpp
+++ b/tools/importJSON.cpp
@@ -36,6 +36,8 @@ public:
ImportJSON() : Tool( "importjson" ){
add_options()
("file",po::value<string>() , "file to import from" )
+ ("idbefore", "create id index before importing " )
+ ("id", "create id index after importing (reccomended) " )
("drop", "drop collection first " )
;
addPositionArg( "file" , 1 );
@@ -64,6 +66,10 @@ public:
_conn.dropCollection( ns.c_str() );
}
+ if ( hasParam( "idbefore" ) ){
+ _conn.ensureIndex( ns.c_str() , BSON( "_id" << 1 ) );
+ }
+
int num = 0;
time_t start = time(0);
@@ -94,6 +100,10 @@ public:
}
}
+ if ( hasParam( "id" ) ){
+ _conn.ensureIndex( ns.c_str() , BSON( "_id" << 1 ) );
+ }
+
return 0;
}
};