using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
using System.Text.Json.Serialization;

namespace Insight.Infrastructure.Entities;

public static partial class MongoDatabaseExtensions
{
    public static IMongoCollection<JobTriggerEntity> JobTrigger(this IMongoDatabase database) => database.GetCollection<JobTriggerEntity>("job_trigger");
}

[BsonIgnoreExtraElements]
public class JobTriggerEntity
{
    [BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")]
    public string? Id { get; set; }

    [BsonElement("_job"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("job")]
    public string? Job { get; set; }

    [BsonElement("_trigger"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("trigger")]
    public string? Trigger { get; set; }

    [BsonElement("insert")]
    public DateTime? Insert { get; set; }

    [BsonElement("update")]
    public DateTime? Update { get; set; }
}