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

namespace Insight.Infrastructure.Entities;

public static partial class MongoDatabaseExtensions
{
    public static IMongoCollection<HostGroupEntity> HostGroup(this IMongoDatabase database) => database.GetCollection<HostGroupEntity>("hostgroup");
}

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

    [BsonElement("name"), Required]
    public string? Name { get; set; }

    [BsonElement("description")]
    public string? Description { get; set; }

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

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