mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 00:56:44 +01:00
option for creating an index before or ater import
This commit is contained in:
parent
c8acc4ac0a
commit
ff7573c65a
@ -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;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user