diff options
Diffstat (limited to 'src/mongo/s/client/shard_local.cpp')
-rw-r--r-- | src/mongo/s/client/shard_local.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/s/client/shard_local.cpp b/src/mongo/s/client/shard_local.cpp index 86ba97eb148..dcf6db33205 100644 --- a/src/mongo/s/client/shard_local.cpp +++ b/src/mongo/s/client/shard_local.cpp @@ -178,5 +178,23 @@ StatusWith<Shard::QueryResponse> ShardLocal::_exhaustiveFindOnConfig( } } +Status ShardLocal::createIndexOnConfig(OperationContext* txn, + const NamespaceString& ns, + const BSONObj& keys, + bool unique) { + invariant(ns.db() == "config" || ns.db() == "admin"); + + try { + DBDirectClient client(txn); + IndexSpec index; + index.addKeys(keys); + index.unique(unique); + client.createIndex(ns.toString(), index); + } catch (const DBException& e) { + return e.toStatus(); + } + + return Status::OK(); +} } // namespace mongo |