31 lines
		
	
	
	
		
			750 B
		
	
	
	
		
			Zig
		
	
	
	
	
	
		
		
			
		
	
	
			31 lines
		
	
	
	
		
			750 B
		
	
	
	
		
			Zig
		
	
	
	
	
	
|  | const std = @import("std");
 | ||
|  | const pgmql = @import("pgmql");
 | ||
|  | const _example = @import("../example.zig");
 | ||
|  | 
 | ||
|  | pub const InvoiceProductModel = pgmql.Model{
 | ||
|  | 	.table = "invoices_products",
 | ||
|  | 	.primaryKey = .{ .single = "id" },
 | ||
|  | 
 | ||
|  | 	.definition = struct {
 | ||
|  | 		pub const id = pgmql.types.Serial{};
 | ||
|  | 		pub const invoiceId = pgmql.types.Int{};
 | ||
|  | 		pub const details = pgmql.types.String{};
 | ||
|  | 		pub const amount = pgmql.types.Decimal{
 | ||
|  | 			.column = .{
 | ||
|  | 				.type = "MONEY",
 | ||
|  | 			},
 | ||
|  | 		};
 | ||
|  | 
 | ||
|  | 		pub const invoice = pgmql.relationships.Model{
 | ||
|  | 			.related = "Invoice",
 | ||
|  | 			.relationship = .{
 | ||
|  | 				.direct = .{ .foreignKey = "invoiceId" },
 | ||
|  | 			},
 | ||
|  | 		};
 | ||
|  | 	},
 | ||
|  | 
 | ||
|  | 	// .crudPolicy = _example.builder.policies.crud(.{ .any = false }),
 | ||
|  | };
 | ||
|  | 
 | ||
|  | pub const InvoiceProduct = InvoiceProductModel.structure();
 |