Given i have an object like this:
class Test
{
public ObjectId Id { get; set; }
public List<OtherObject> OtherObjects { get; set; }
}
class OtherObjects
{
public string Name { get; set; }
public string Value { get; set; }
}
I need to create an index in Name and Value, since i’ll be querying on those fields. Using driver i’m doing this:
var index = new CreateIndexModel<Test>(Builders<Test>.IndexKeys
.Ascending("OtherObjects.Name")
.Ascending("OtherObjects.Value")
);
It would be great to have support for that using OwnsMany for model builder, something like this:
model.Entity<Test>().OwnsMany(x => x.OtherObjects, a =>
{
a.HasIndex(e => e.Name);
a.HasIndex(e => e.Value);
});
Do you think this is feasible to implement? For us it’s the last usage of Mongo.Driver for creating indexes, everything else we can do using the HasIndex function