I am using the MongoDB C# driver to create an index
When my app starts up, it creates the index as below
await collection.Indexes.CreateOneAsync(new BsonDocument("code", 1), new CreateIndexOptions() { Unique = true, Sparse = true });
My question is this: If the index already exists, the index will not be re-created/indexed again, correct?
You can add the driver to your application to work with MongoDB using the C++11 or later standard.
By developing with C# and MongoDB together one opens up a world of possibilities. Console, window, and web applications are all possible. As are cross-platform mobile applications using the Xamarin framework.
The official MongoDB Node. js driver allows Node. js applications to connect to MongoDB and work with data. The driver features an asynchronous API which allows you to interact with MongoDB using Promises or via traditional callbacks.
Yes.
As long as the parameters don't change (e.g "code"
becomes "Code"
or Sparse
becomes false
) the index will not be recreated and the operation will be a no-op.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With