thumbnail service wip
This commit is contained in:
26
AobaCore/Services/AobaIndexCreationService.cs
Normal file
26
AobaCore/Services/AobaIndexCreationService.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using AobaCore.Models;
|
||||
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
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)
|
||||
{
|
||||
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