public string CreateIndex(Index index, bool unique = false)
 {
     var indexName = IndexName(index);
       var doc = new Doc { {"name", indexName},
                   {"ns", FullName},
                   {"key", index.ToDoc()},
                   {"unique", unique} };
       Database.GetCollection("system.indexes").Insert(doc);
       return indexName;
 }
 public string EnsureIndex(Index index)
 {
     /* Since Mongo 1.1.3 the insert function on the server check whether
        * the index already exists in pdfile.cpp so tracking indexes here isn't
        * worth the effort. So here, Ensure can just be an alias for Create.
        */
       return CreateIndex(index);
 }
 private static string IndexName(Index index)
 {
     return string.Join("_", index.Select(x => string.Join("_", x.Key, (int)x.Value)));
 }
 public void DropIndex(Index index)
 {
     DropIndex(IndexName(index));
 }