Closed juranki closed 3 years ago
Thanks for your email and for the bug reports. I've pushed a fix to this repo.
You are right, the ModelConstructorOptions.models should be .fields.
You need to provide the options to specify the schema model fields if you are using the Model constructor. However, a more common pattern is to define all models in the table schema and then use getModel.
let EmailValidationModel: Model< EmailValidationModel > = table.getModel('EmailValidationModel')
This has the benefit of a centralized schema. We're also working on some promising design tools where a centralized schema is pretty key. So I'd recommend this design path.
If you define the fields via the Model constructor. Note:
If you don't provide timestamps
it defaults to your table.timestamps which defaults to true.
If you don't provide indexes, then it will use the table indexes defined via the schema or the default indexes if not defined. The default indexes are:
primary: {
hash: 'pk',
sort: 'sk',
},
First, I really like the concept of onetable! It makes working with single table designs a lot easier.
I wasn't able to make Model work with instructions in README, but had to add options parameter to the Model constructor
Also, typing suggest that options could include
models
, but constructor expectsfields