You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
└── user.go # User model (if defined in YAML, DO NOT EDIT)
70
82
```
71
83
72
84
### Using Generated Stores
@@ -162,7 +174,7 @@ models:
162
174
| `output_dir` | Directory for generated files | Optional (defaults to `stores/<name>`) |
163
175
| `interface` | Interface name — **recommended: `<Name>Store`** (e.g., `UserStore`) | Optional (defaults to `<Name>Store`) |
164
176
| `implementation` | Implementation struct name (e.g., `userStore`) | Optional (defaults to `<name>Store`) |
165
-
| `queries` | Array of database queries | **Yes** |
177
+
| `queries` | Array of database queries | Optional |
166
178
167
179
> **⚠️ Naming Convention:** The registry (`stores/all.go`) automatically appends `"Store"` when building constructor calls. To avoid compilation errors, always name your interface as `<Name>Store` (e.g., `UserStore`) and the generated constructor will be `New<Name>Store()`.
1.**Never Edit Generated Files**: Files marked `DO NOT EDIT`(`interface.go`, `all.go`) are overwritten on every generation. Keep custom SQL logic in your implementation file (e.g., `userStore.go`).
324
+
1.**Know Which Files Are Auto-Generated**: Only `interface.go` and `all.go` are marked `DO NOT EDIT`and are overwritten on every `gofr store generate`. The implementation stub (`<name>.go` or `<name>Store.go`) created by `gofr store init` is editable — this is where you add your SQL logic.
313
325
2.**Use `<Name>Store` Interface Names**: This ensures the registry and constructor align correctly.
314
326
3.**Commit your YAML**: Treat `store.yaml` as source of truth. Re-run `gofr store generate` after every change.
315
327
4.**Reference Existing Models**: If you already have model structs, use the `path` + `package` fields to avoid duplication.
0 commit comments