Tag Archives: spod

Haxe SPOD: Specifying a unique field

Haxe has a very nice library called SPOD Macros which allows us to manipulate database tables as strictly-typed objects instead of dealing with the plain-text SQL commands and the clumsy result sets/arrays of untyped row objects.

The Problem

As at Haxe 3.0.1, SPOD does not provide a compile-time solution (I mean metadata like @:table and @:relation) to specify a field to be unique. One of the solution is to first create the table in Haxe, then use a database management tool such as phpMyAdmin to configure the column to be unique. However, I would like to do this in my Haxe code, after all we are programmers!

Continue reading Haxe SPOD: Specifying a unique field