The problem here is that to generate the above hook, we need to generate TodoModel but to generate TodoModel, we need to generate code to initialise DataStore like this
The problem here is that the user will need to edit this config. We don't want users to edit any generated file.
How do we save users from boilerplate code without generating the config?
Possible Solutions
There was a suggestion to generate something like this
let TodoModel
let UserModel
export function createModels(datastore: DataStore) {
TodoModel = datastore.setupModel<Todo>(schema.Todo);
UserModel = datastore.setupModel<User>(schema.User);
}
export { TodoModel, UserModel };
This can work. Users will have to do something like this
import { createModels, schema } from "./generated";
const datastore = ... // create datastore
// if users want to edit schema, they'll have to do it here
createModels(datastore);
export * from "./generated";
We want to generate hooks for Models, see example below;
The problem here is that to generate the above hook, we need to generate
TodoModel
but to generateTodoModel
, we need to generate code to initialise DataStore like thisThe problem here is that the user will need to edit this config. We don't want users to edit any generated file. How do we save users from boilerplate code without generating the config?
Possible Solutions
There was a suggestion to generate something like this
This can work. Users will have to do something like this
@wtrocki @kingsleyzissou