@@ -42,11 +42,6 @@ public MongoNonceRepository(IMongoDatabase database, MongoNonceOptions options)
4242 _collection . Indexes . CreateOne ( new CreateIndexModel < Token > (
4343 Builders < Token > . IndexKeys . Ascending ( nameof ( IdentifiableToken . Identifier ) ) ) ) ;
4444
45- _collection . Indexes . CreateOne ( new CreateIndexModel < Token > (
46- Builders < Token > . IndexKeys . Combine (
47- Builders < Token > . IndexKeys . Ascending ( nameof ( Token . Nonce ) ) ,
48- Builders < Token > . IndexKeys . Ascending ( nameof ( Token . IsDeleted ) ) ) ) ) ;
49-
5045 _collection . Indexes . CreateOne ( new CreateIndexModel < Token > (
5146 Builders < Token > . IndexKeys . Ascending ( nameof ( Token . ExpirationDate ) ) ,
5247 new CreateIndexOptions
@@ -58,16 +53,19 @@ public MongoNonceRepository(IMongoDatabase database, MongoNonceOptions options)
5853 public async ValueTask InsertOneAsync (
5954 Token token , CancellationToken cancellationToken )
6055 {
56+ await _collection . InsertOneAsync ( token , cancellationToken : cancellationToken ) ;
57+
6158 if ( token . ExtraProperties != null )
6259 {
63- foreach ( KeyValuePair < string , string > searchAttribute in token . ExtraProperties )
60+ var indexOptions = new CreateIndexOptions { Background = true } ;
61+
62+ foreach ( KeyValuePair < string , object > extraProperty in token . ExtraProperties )
6463 {
6564 _collection . Indexes . CreateOne ( new CreateIndexModel < Token > (
66- Builders < Token > . IndexKeys . Ascending ( $ "{ nameof ( token . ExtraProperties ) } .{ searchAttribute . Key } ") ) ) ;
65+ Builders < Token > . IndexKeys . Ascending (
66+ $ "{ nameof ( token . ExtraProperties ) } .{ extraProperty . Key } ") , indexOptions ) ) ;
6767 }
6868 }
69-
70- await _collection . InsertOneAsync ( token , cancellationToken : cancellationToken ) ;
7169 }
7270
7371 public async ValueTask < Token ? > TakeOneAsync (
0 commit comments