ufront / ufront-orm

The Object Relational Mapper, allows easy, type-safe access to your database. Builds on Haxe's SPOD but adds macro powered relationships, validation and client side usage
MIT License
13 stars 4 forks source link

Suggestion: let define custom id field #4

Open sebpatu opened 10 years ago

sebpatu commented 10 years ago

Hi, The ufront ORM will automatically add the field id, but if i define an id field in my Spod, i get a compile error. It would be good if the ufront macro let users define custom fields, and add it automatically only when it does not exist.

Thanks Seb

jasononeil commented 10 years ago

At the moment the "id:SUId" field is not added through the macro, but rather in the base ufront.db.Object class.

I think one workaround may be to split it into:

So that way you could use BaseObject and specify your own ID.

Some work would be required to get this to work cleanly with BelongsTo<> and ManyToMany and HasMany relations, it is certainly possible. Pull requests welcome :) Otherwise I'll look at it when I get time.