using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;

namespace Nalu.Web.Data.Models;

/// <summary>
/// One document per (api_key + date). Counters updated atomically via $inc.
/// </summary>
public class UsageDaily
{
    [BsonId]
    [BsonRepresentation(BsonType.ObjectId)]
    public string Id { get; set; } = ObjectId.GenerateNewId().ToString();

    [BsonElement("api_key")]
    public required string ApiKey { get; set; }

    [BsonElement("plan")]
    public required string Plan { get; set; }

    /// Format: "YYYY-MM-DD"
    [BsonElement("date")]
    public required string Date { get; set; }

    [BsonElement("daily_count")]
    public int DailyCount { get; set; }

    [BsonElement("monthly_count")]
    public int MonthlyCount { get; set; }

    [BsonElement("year_month")]
    public required string YearMonth { get; set; }  // "YYYY-MM"
}
