GenieFramework / SearchLight.jl

ORM layer for Genie.jl, the highly productive Julia web framework
https://genieframework.com
MIT License
139 stars 16 forks source link

How to map model to existing singular table name #61

Closed Vladislav-Zolotaryov closed 2 years ago

Vladislav-Zolotaryov commented 2 years ago

Hello.

I have an existing db schema I need to integrate with. But I cannot seem to find how to override table name for a model or at least disable pluralization of the model name.

The table name is 'world', the model is 'World', but it is always queried as 'worlds'.

Is this possible? If no, please add such a feature.

FrankUrbach commented 2 years ago

The easiest way to get it right is implementing the name of your table by yourself:

function SearchLigth.table(m::Type(World))::String "world" end

This should be sufficient. Your World model has to be a subtype of AbstractModel. That's it.

HTH Frank

Vladislav-Zolotaryov commented 2 years ago

Thank you!