const jetquery = @import("jetzig").jetquery;

pub const Blog = jetquery.Model(
    @This(),
    "blogs",
    struct {
        id: i32,
        title: []const u8,
        content: ?[]const u8,
        blob: []const u8,
        created_at: jetquery.DateTime,
        updated_at: jetquery.DateTime,
    },
    .{},
);

pub const Session = jetquery.Model(
    @This(),
    "sessions",
    struct {
        id: i32,
        session_id: []const u8,
        created_at: jetquery.DateTime,
        updated_at: jetquery.DateTime,
    },
    .{},
);

pub const BlogTag = jetquery.Model(
    @This(),
    "blog_tags",
    struct {
        id: i32,
        blog_id: i32,
        tag_id: i32,
        created_at: jetquery.DateTime,
        updated_at: jetquery.DateTime,
    },
    .{
        .relations = .{
            .blog = jetquery.belongsTo(.Blog, .{}),
            .tag = jetquery.belongsTo(.Tag, .{}),
        },
    },
);

pub const Tag = jetquery.Model(
    @This(),
    "tags",
    struct {
        id: i32,
        name: []const u8,
        emoji: ?[]const u8,
        created_at: jetquery.DateTime,
        updated_at: jetquery.DateTime,
    },
    .{
        .relations = .{
            .blog_tags = jetquery.hasMany(.BlogTag, .{}),
        },
    },
);
