[CSHARP-2421] How can I EnsureIndex with String. Created: 19/Oct/18 Updated: 27/Oct/23 Resolved: 19/Oct/18 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | API |
| Affects Version/s: | 2.7.0 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Krittayot Techasombooranakit | Assignee: | Robert Stam |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | question | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Since EnsureIndexes methods are obsolete How can I ensure indexes using strings? |
| Comments |
| Comment by Robert Stam [ 19/Oct/18 ] | |||
|
collection.EnsureIndex is deprecated and in any case was only available in the Legacy API. It has been replaced with collection.Indexes.CreateOne, Not sure what you mean by "using strings". If by strings you mean the names of the elements you want to index you can create an index like this:
Note: CreateOne is a no-op on the server if the index already exists.
|