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<JobTaskEntity> JobTask(this IMongoDatabase database) => database.GetCollection<JobTaskEntity>("job_task");
}

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

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

    [BsonElement("_task"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("task")]
    public string? Task { get; set; }

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

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