public void OnConfiguring(
            IMongoCollectionBuilder <MediaFace> builder)
        {
            builder
            .WithCollectionName(CollectionNames.Face)
            .AddBsonClassMap <MediaFace>(cm =>
            {
                cm.AutoMap();
                cm.MapIdMember(c => c.Id);
            })
            .WithCollectionSettings(s => s.ReadConcern    = ReadConcern.Majority)
            .WithCollectionSettings(s => s.ReadPreference = ReadPreference.Nearest)
            .WithCollectionConfiguration(collection =>
            {
                var mediaIdIndex = new CreateIndexModel <MediaFace>(
                    Builders <MediaFace> .IndexKeys
                    .Ascending(c => c.MediaId),
                    new CreateIndexOptions {
                    Unique = false
                });

                var personIdIndex = new CreateIndexModel <MediaFace>(
                    Builders <MediaFace> .IndexKeys
                    .Descending(c => c.PersonId),
                    new CreateIndexOptions {
                    Unique = false
                });

                collection.Indexes.CreateOne(mediaIdIndex);
                collection.Indexes.CreateOne(personIdIndex);
            });
        }
 public void OnConfiguring(
     IMongoCollectionBuilder <Component> builder)
 {
     builder
     .WithCollectionName("component")
     .AddBsonClassMap <Component>(cm =>
     {
         cm.AutoMap();
         cm.MapIdMember(c => c.Id);
     })
     .WithCollectionSettings(s => s.ReadConcern    = ReadConcern.Majority)
     .WithCollectionSettings(s => s.ReadPreference = ReadPreference.Nearest)
     .WithCollectionConfiguration(collection =>
     {
         collection.Indexes.CreateOne(
             new CreateIndexModel <Component>(
                 Builders <Component> .IndexKeys.Ascending(project => project.Name),
                 new CreateIndexOptions
         {
             Collation = new Collation(
                 "en",
                 strength: CollationStrength.Secondary),
             Unique = true
         }));
     });
 }
Ejemplo n.º 3
0
 public void OnConfiguring(IMongoCollectionBuilder <User> mongoCollectionBuilder)
 {
     mongoCollectionBuilder
     .WithCollectionName("users")
     .AddBsonClassMap <User>(ConfigureUserClassMap())
     .WithCollectionSettings(ConfigureCollectionSettings())
     .WithCollectionConfiguration(ConfigureIndexes());
 }
        public void OnConfiguring(
            IMongoCollectionBuilder <Media> builder)
        {
            builder
            .WithCollectionName(CollectionNames.Media)
            .AddBsonClassMap <Media>(cm =>
            {
                cm.AutoMap();
                cm.MapIdMember(c => c.Id);
            })
            .AddBsonClassMap <MediaThumbnail>(cm =>
            {
                cm.AutoMap();
                cm.UnmapMember(x => x.Data);
            })
            .AddBsonClassMap <GeoPoint>(cm =>
            {
                cm.MapMember(x => x.Type)
                .SetElementName("type");

                cm.MapMember(x => x.Coordinates)
                .SetElementName("coordinates");
            })
            .WithCollectionSettings(s => s.ReadConcern    = ReadConcern.Majority)
            .WithCollectionSettings(s => s.ReadPreference = ReadPreference.Nearest)
            .WithCollectionConfiguration(async collection =>
            {
                var geoIndex = new CreateIndexModel <Media>(
                    Builders <Media> .IndexKeys
                    .Geo2DSphere(x => x.GeoLocation.Point),
                    new CreateIndexOptions {
                    Unique = false
                });

                collection.Indexes.CreateOne(geoIndex);

                var folderIndex = new CreateIndexModel <Media>(
                    Builders <Media> .IndexKeys
                    .Ascending(x => x.State)
                    .Ascending(c => c.Folder)
                    .Descending(c => c.DateTaken),
                    new CreateIndexOptions {
                    Unique = false
                });

                var importedAtIndex = new CreateIndexModel <Media>(
                    Builders <Media> .IndexKeys
                    .Descending(c => c.Source.ImportedAt),
                    new CreateIndexOptions {
                    Unique = false
                });

                collection.Indexes.CreateOne(folderIndex);
            });
        }
Ejemplo n.º 5
0
 public void OnConfiguring(IMongoCollectionBuilder <Foo> mongoCollectionBuilder)
 {
     mongoCollectionBuilder
     .WithCollectionName("TheArtOfFoo")
     .AddBsonClassMap <Foo>(cm =>
     {
         cm.AutoMap();
         cm.MapIdMember(c => c.FooId);
     })
     .WithCollectionSettings(ConfigureSettings)
     .WithCollectionConfiguration(ConfigureIndexes);
 }
Ejemplo n.º 6
0
 public void OnConfiguring(
     IMongoCollectionBuilder <Application> builder)
 {
     builder
     .WithCollectionName("application")
     .AddBsonClassMap <Application>(cm =>
     {
         cm.AutoMap();
         cm.MapIdMember(c => c.Id);
     })
     .WithCollectionSettings(s => s.ReadConcern    = ReadConcern.Majority)
     .WithCollectionSettings(s => s.ReadPreference = ReadPreference.Nearest)
     .WithCollectionConfiguration(collection =>
     {
     });
 }
Ejemplo n.º 7
0
 public void OnConfiguring(
     IMongoCollectionBuilder <MagicIdentityResource> mongoCollectionBuilder)
 {
     mongoCollectionBuilder
     .WithCollectionName("identityResource")
     .AddBsonClassMap <MagicIdentityResource>(cm =>
     {
         cm.AutoMap();
         cm.MapIdMember(c => c.Id);
     })
     .WithCollectionSettings(s => s.ReadConcern    = ReadConcern.Majority)
     .WithCollectionSettings(s => s.ReadPreference = ReadPreference.Nearest)
     .WithCollectionConfiguration(collection =>
     {
     });
 }
        public void OnConfiguring(
            IMongoCollectionBuilder <MediaAI> builder)
        {
            builder
            .WithCollectionName(CollectionNames.MediaAI)
            .AddBsonClassMap <MediaAI>(cm =>
            {
                cm.AutoMap();
                cm.MapIdMember(c => c.Id);
            })
            .WithCollectionSettings(s => s.ReadConcern    = ReadConcern.Majority)
            .WithCollectionSettings(s => s.ReadPreference = ReadPreference.Nearest)
            .WithCollectionConfiguration(collection =>
            {
                var mediaIdIndex = new CreateIndexModel <MediaAI>(
                    Builders <MediaAI> .IndexKeys
                    .Ascending(c => c.MediaId),
                    new CreateIndexOptions {
                    Unique = true
                });

                collection.Indexes.CreateOne(mediaIdIndex);

                var objectNameIndex = new CreateIndexModel <MediaAI>(
                    Builders <MediaAI> .IndexKeys
                    .Ascending("Objects.Name")
                    .Ascending("Objects.Confidence"),
                    new CreateIndexOptions {
                    Unique = false
                });

                collection.Indexes.CreateOne(objectNameIndex);

                var tagNameIndex = new CreateIndexModel <MediaAI>(
                    Builders <MediaAI> .IndexKeys
                    .Ascending("Tags.Name")
                    .Ascending("Tags.Confidence"),
                    new CreateIndexOptions {
                    Unique = false
                });

                collection.Indexes.CreateOne(tagNameIndex);
            });
        }
 public void OnConfiguring(IMongoCollectionBuilder <MagicApiScope> mongoCollectionBuilder)
 {
     mongoCollectionBuilder
     .WithCollectionName("apiScope")
     .AddBsonClassMap <MagicApiScope>(cm =>
     {
         cm.AutoMap();
         cm.MapIdMember(c => c.Id);
     })
     .WithCollectionSettings(s => s.ReadConcern    = ReadConcern.Majority)
     .WithCollectionSettings(s => s.ReadPreference = ReadPreference.Nearest)
     .WithCollectionConfiguration(collection =>
     {
         var nameIndex = new CreateIndexModel <MagicApiScope>(
             Builders <MagicApiScope> .IndexKeys.Ascending(c => c.Name),
             new CreateIndexOptions {
             Unique = true
         });
         collection.Indexes.CreateOne(nameIndex);
     });
 }
Ejemplo n.º 10
0
        public void OnConfiguring(IMongoCollectionBuilder <Blog> mongoCollectionBuilder)
        {
            mongoCollectionBuilder
            .WithCollectionName("blogs")
            .AddBsonClassMap <Blog>(cm =>
            {
                cm.AutoMap();
                cm.MapIdMember <Guid>(c => c.Id);
            })
            .WithCollectionSettings(settings => settings.ReadConcern    = ReadConcern.Majority)
            .WithCollectionSettings(settings => settings.ReadPreference = ReadPreference.Nearest)
            .WithCollectionConfiguration(collection =>
            {
                var timestampIndex = new CreateIndexModel <Blog>(
                    Builders <Blog> .IndexKeys.Ascending(blog => blog.TimeStamp),
                    new CreateIndexOptions {
                    Unique = false
                });

                collection.Indexes.CreateOne(timestampIndex);
            });
        }
 public void OnConfiguring(IMongoCollectionBuilder <ClaimedVersion> builder)
 {
     builder
     .WithCollectionName("claimed_version")
     .AddBsonClassMap <ClaimedVersion>(cm =>
     {
         cm.AutoMap();
         cm.MapIdMember(c => c.Id);
     })
     .WithCollectionSettings(s => s.ReadConcern    = ReadConcern.Majority)
     .WithCollectionSettings(s => s.ReadPreference = ReadPreference.Nearest)
     .WithCollectionConfiguration(collection =>
     {
         CreateIndexModel <ClaimedVersion>[] indexes =
         {
             new(Builders <ClaimedVersion> .IndexKeys.Ascending(project => project.GitVersion),
                 new CreateIndexOptions {
                 Name = "GitVersion_ASC"
             }
                 )
         };
         collection.Indexes.CreateMany(indexes);
     });
 public void OnConfiguring(IMongoCollectionBuilder <PublishedApplicationPart> builder)
 {
     builder
     .WithCollectionName("published_application_part")
     .AddBsonClassMap <PublishedApplicationPart>(cm =>
     {
         cm.AutoMap();
         cm.MapIdMember(c => c.Id);
     })
     .WithCollectionSettings(s => s.ReadConcern    = ReadConcern.Majority)
     .WithCollectionSettings(s => s.ReadPreference = ReadPreference.Nearest)
     .WithCollectionConfiguration(collection =>
     {
         CreateIndexModel <PublishedApplicationPart>[] indexes =
         {
             new(IndexKeys.Ascending(project => project.Part.Id),
                 new CreateIndexOptions {
                 Name = "PartId_ASC"
             }
                 )
         };
         collection.Indexes.CreateMany(indexes);
     });
        public void OnConfiguring(IMongoCollectionBuilder <PersistedGrant> mongoCollectionBuilder)
        {
            mongoCollectionBuilder
            .WithCollectionName("grant")
            .AddBsonClassMap <PersistedGrant>(cm =>
            {
                cm.AutoMap();
                cm.MapIdMember(c => c.Key);
            })
            .WithCollectionSettings(s => s.ReadConcern    = ReadConcern.Majority)
            .WithCollectionSettings(s => s.ReadPreference = ReadPreference.Nearest)
            .WithCollectionConfiguration(collection =>
            {
                var ttlIndex = new CreateIndexModel <PersistedGrant>(
                    Builders <PersistedGrant> .IndexKeys.Ascending(c => c.CreationTime),
                    new CreateIndexOptions
                {
                    Unique      = false,
                    ExpireAfter = TimeSpan.FromDays(2)
                });

                collection.Indexes.CreateOne(ttlIndex);
            });
        }
    public void OnConfiguring(
        IMongoCollectionBuilder <VariableValue> builder)
    {
        builder
        .WithCollectionName("variable_value")
        .AddBsonClassMap <VariableValue>(cm =>
        {
            cm.AutoMap();
            cm.MapIdMember(c => c.Id);
        })
        .WithCollectionSettings(s => s.ReadConcern    = ReadConcern.Majority)
        .WithCollectionSettings(s => s.ReadPreference = ReadPreference.Nearest)
        .WithCollectionConfiguration(collection =>
        {
            var variableIdIndex = new CreateIndexModel <VariableValue>(
                Builders <VariableValue> .IndexKeys
                .Descending(c => c.Key.VariableId),
                new CreateIndexOptions {
                Unique = false
            });

            var applicationIdIndex = new CreateIndexModel <VariableValue>(
                Builders <VariableValue> .IndexKeys
                .Descending(c => c.Key.ApplicationId),
                new CreateIndexOptions {
                Unique = false
            });

            var environmentIdIndex = new CreateIndexModel <VariableValue>(
                Builders <VariableValue> .IndexKeys
                .Descending(c => c.Key.EnvironmentId),
                new CreateIndexOptions {
                Unique = false
            });

            var partIdIndex = new CreateIndexModel <VariableValue>(
                Builders <VariableValue> .IndexKeys
                .Descending(c => c.Key.PartId),
                new CreateIndexOptions {
                Unique = false
            });

            var variableKeyCompoundIndex = new CreateIndexModel <VariableValue>(
                Builders <VariableValue> .IndexKeys.Combine(
                    Builders <VariableValue> .IndexKeys.Ascending(di => di.Key.VariableId),
                    Builders <VariableValue> .IndexKeys.Ascending(di => di.Key.ApplicationId),
                    Builders <VariableValue> .IndexKeys.Descending(di => di.Key.PartId),
                    Builders <VariableValue> .IndexKeys.Descending(di => di.Key.EnvironmentId)),
                new CreateIndexOptions
            {
                Unique     = true,
                Background = false
            });

            collection.Indexes.CreateMany(new[]
            {
                variableIdIndex,
                applicationIdIndex,
                environmentIdIndex,
                partIdIndex,
                variableKeyCompoundIndex
            });
        });
    }
    public void OnConfiguring(IMongoCollectionBuilder <ChangeLog> builder)
    {
        builder
        .WithCollectionName("change_log")
        .AddBsonClassMap <ChangeLog>(cm =>
        {
            cm.AutoMap();
            cm.MapIdMember(c => c.Id);
            cm.SetIsRootClass(true);
        })
        .AddBsonClassMap <CreateApplicationChange>(cm => cm.AutoMap())
        .AddBsonClassMap <RenameApplicationChange>(cm => cm.AutoMap())
        .AddBsonClassMap <RenameApplicationPartChange>(cm => cm.AutoMap())
        .AddBsonClassMap <AddComponentToApplicationPartChange>(cm => cm.AutoMap())
        .AddBsonClassMap <AddPartToApplicationChange>(cm => cm.AutoMap())
        .AddBsonClassMap <RemovePartFromApplicationChange>(cm => cm.AutoMap())
        .AddBsonClassMap <RemoveComponentFromApplicationPartChange>(cm => cm.AutoMap())
        .AddBsonClassMap <ApplicationPartComponentValuesChange>(cm => cm.AutoMap())
        .AddBsonClassMap <CreateComponentChange>(cm => cm.AutoMap())
        .AddBsonClassMap <PublishedApplicationPartChange>(cm => cm.AutoMap())
        .AddBsonClassMap <RemoveComponentChange>(cm => cm.AutoMap())
        .AddBsonClassMap <RenameComponentChange>(cm => cm.AutoMap())
        .AddBsonClassMap <ComponentSchemaChange>(cm => cm.AutoMap())
        .AddBsonClassMap <ComponentValuesChange>(cm => cm.AutoMap())
        .AddBsonClassMap <CreateVariableChange>(cm => cm.AutoMap())
        .AddBsonClassMap <RenameVariableChange>(cm => cm.AutoMap())
        .AddBsonClassMap <DeleteVariableValueChange>(cm => cm.AutoMap())
        .AddBsonClassMap <VariableValueChange>(cm => cm.AutoMap())
        .WithCollectionSettings(s => s.ReadConcern    = ReadConcern.Majority)
        .WithCollectionSettings(s => s.ReadPreference = ReadPreference.Nearest)
        .WithCollectionConfiguration(collection =>
        {
            collection.Indexes.CreateMany(new CreateIndexModel <ChangeLog>[]
            {
                new(IndexKeys.Ascending(WellKnownChangeLogFields.ApplicationId),
                    new() { Name = "ChangeLog-Change-ApplicationId" }),

                new(IndexKeys.Ascending(WellKnownChangeLogFields.ApplicationPartId),
                    new() { Name = "ChangeLog-Change-PartId" }),

                new(IndexKeys.Ascending(WellKnownChangeLogFields.PartComponentId),
                    new() { Name = "ChangeLog-Change-PartComponentId" }),

                new(IndexKeys.Ascending(WellKnownChangeLogFields.VariableId),
                    new() { Name = "ChangeLog-Change-VariableId" }),

                new(IndexKeys.Ascending(WellKnownChangeLogFields.ComponentId),
                    new() { Name = "ChangeLog-Change-ComponentId" }),

                new(IndexKeys.Combine(
                        IndexKeys.Ascending(WellKnownChangeLogFields.ApplicationId),
                        IndexKeys.Ascending(WellKnownChangeLogFields.ApplicationVersion)),
                    new() { Name = "ChangeLog-Change-ApplicationIdAndVersion" }),

                new(IndexKeys.Combine(
                        IndexKeys.Ascending(WellKnownChangeLogFields.ApplicationPartId),
                        IndexKeys.Ascending(WellKnownChangeLogFields.ApplicationPartVersion)),
                    new() { Name = "ChangeLog-Change-PartIdAndVersion" }),

                new(IndexKeys.Combine(
                        IndexKeys.Ascending(WellKnownChangeLogFields.PartComponentId),
                        IndexKeys.Ascending(WellKnownChangeLogFields.PartComponentVersion)),
                    new() { Name = "ChangeLog-Change-PartComponentIdAndVersion" }),

                new(IndexKeys.Combine(
                        IndexKeys.Ascending(WellKnownChangeLogFields.VariableId),
                        IndexKeys.Ascending(WellKnownChangeLogFields.VariableVersion)),
                    new() { Name = "ChangeLog-Change-VariableIdAndVersion" }),

                new(IndexKeys.Combine(
                        IndexKeys.Ascending(WellKnownChangeLogFields.ComponentId),
                        IndexKeys.Ascending(WellKnownChangeLogFields.ComponentVersion)),
                    new() { Name = "ChangeLog-Change-ComponentIdAndVersion" })
            });
        });