const std = @import("std"); /// Configure a "one to one" relationship. pub const OneConfiguration = union(enum) { /// Direct one-to-one relationship using a local foreign key. direct: struct { /// The local foreign key name. foreignKey: []const u8, /// Associated model key name. /// Use the default key name of the associated model. modelKey: ?[]const u8 = null, }, /// Reverse one-to-one relationship using distant foreign key. reverse: struct { /// The distant foreign key name. /// Use the default key name of the related model. foreignKey: ?[]const u8 = null, /// Current model key name. /// Use the default key name of the current model. modelKey: ?[]const u8 = null, }, /// Used when performing a one-to-one relationship through an association table. through: struct { /// Name of the join table. table: []const u8, /// The local foreign key name. /// Use the default key name of the current model. foreignKey: ?[]const u8 = null, /// The foreign key name in the join table. joinForeignKey: []const u8, /// The model key name in the join table. joinModelKey: []const u8, /// Associated model key name. /// Use the default key name of the associated model. modelKey: ?[]const u8 = null, }, }; /// Type of a related model field. pub const Model = struct { /// Name of the related model definition. related: []const u8, /// Configuration of the relationship. relationship: OneConfiguration, }; /// Configure a "one to many" or "many to many" relationship. pub const ManyConfiguration = union(enum) { /// Direct one-to-many relationship using a distant foreign key. direct: struct { /// The distant foreign key name pointing to the current model. foreignKey: []const u8, /// Current model key name. /// Use the default key name of the current model. modelKey: ?[]const u8 = null, }, /// Used when performing a many-to-many relationship through an association table. through: struct { /// Name of the join table. table: []const u8, /// The local foreign key name. /// Use the default key name of the current model. foreignKey: ?[]const u8 = null, /// The foreign key name in the join table. joinForeignKey: []const u8, /// The model key name in the join table. joinModelKey: []const u8, /// Associated model key name. /// Use the default key name of the associated model. modelKey: ?[]const u8 = null, }, }; /// Type of related models collection field. pub const Models = struct { /// Name of the related model definition. related: []const u8, /// Configuration of the relationship. relationship: OneConfiguration, };