Having trouble performing basic inserts of a document into a collection. Some details first:
- Asp.Net Core
- MongoDB.Driver 2.13
- z/TPF Version 1.1
- MongoDB Version 2.6.5
I’m trying to insert a document into a collection that does not contain a fixed ordinal address. There are documents in the collection that have unique “_id” fields, but the collection itself doesn’t have a fixed address.
I try to do the following:
var document1 = new BsonDocument { { "Key1", "test1" }, { "Key2", "test2"}, { "datetime", DateTime.Now }, }; try { _mongoMsgDetailCollection4O.InsertOne(document1); } catch (MongoWriteException e) { Console.WriteLine(e.Message); }
The error I get is:
Command Failed. MONG0018E 14.45.38 The _index field must exist in the input document.
How and where do I define this index in the input document? All the CRUD examples I’ve found don’t show having to define an index. Even if I define the index parameter in the document, I still get the same error.
var document1 = new BsonDocument { { "Key1", "test1" }, { "Key2", "test2"}, { "datetime", DateTime.Now }, {"_index", "SineInMsgCustom"} };
I am expecting that the document be inserted and that the ObjectId of the document can be retrieved to be recorded elsewhere in my application. Thanks for any help you can offer.