JJ Colocate
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
using AobaCore.Models;
|
||||
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization;
|
||||
using MongoDB.Bson.Serialization.Serializers;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace AobaCore.Services;
|
||||
|
||||
public class AobaIndexCreationService(IMongoDatabase db): BackgroundService
|
||||
{
|
||||
private readonly IMongoCollection<Media> _media = db.GetCollection<Media>("media");
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
BsonSerializer.RegisterSerializer(new EnumSerializer<ThumbnailSize>(BsonType.String));
|
||||
var textKeys = Builders<Media>.IndexKeys
|
||||
.Text(m => m.Filename);
|
||||
|
||||
var textModel = new CreateIndexModel<Media>(textKeys, new CreateIndexOptions
|
||||
{
|
||||
Name = "Text",
|
||||
Background = true
|
||||
});
|
||||
|
||||
await _media.EnsureIndexAsync(textModel);
|
||||
}
|
||||
using AobaCore.Models;
|
||||
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization;
|
||||
using MongoDB.Bson.Serialization.Serializers;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace AobaCore.Services;
|
||||
|
||||
public class AobaIndexCreationService(IMongoDatabase db): BackgroundService
|
||||
{
|
||||
private readonly IMongoCollection<Media> _media = db.GetCollection<Media>("media");
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
BsonSerializer.RegisterSerializer(new EnumSerializer<ThumbnailSize>(BsonType.String));
|
||||
var textKeys = Builders<Media>.IndexKeys
|
||||
.Text(m => m.Filename);
|
||||
|
||||
var textModel = new CreateIndexModel<Media>(textKeys, new CreateIndexOptions
|
||||
{
|
||||
Name = "Text",
|
||||
Background = true
|
||||
});
|
||||
|
||||
await _media.EnsureIndexAsync(textModel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user