drift icon indicating copy to clipboard operation
drift copied to clipboard

[Question] DataClass names

Open fernando-s97 opened this issue 5 years ago • 3 comments

Hi!

If I have a table called Todos, Moor will generate a data class called Todo to represent my rows, but I already have a Todo data class that I've created to represent the todos in my project.

How can I change the generated Todo data class name to TodoRow?

fernando-s97 avatar Sep 16 '20 19:09 fernando-s97

If you are using moor files you can specify an "alias" at the end of your create table statement

CREATE TABLE (
...
) as TodoRow;

davidmartos96 avatar Sep 16 '20 20:09 davidmartos96

I'm using dart code.

The alias won't change only the table name?

fernando-s97 avatar Sep 16 '20 20:09 fernando-s97

Then you can do the following:

@DataClassName('TodoRow')
class Todos extends Table {

Check out the docs webpage. It has precisely an example of what you are asking ^^

davidmartos96 avatar Sep 17 '20 07:09 davidmartos96