NeoSQL feeds a table's column information into a template pack to produce source code such as entities, mappers and screens. It takes three steps: assign template packs to the project, refine the entity name and fields for each table, and review the result in the result window before installing or downloading it. Creating and editing template packs is explained in Template packs, and the variables and functions templates use in Template syntax.
| Feature | Environment and workflow |
|---|---|
| Preview, download as ZIP | Available on the web and desktop. |
| Install into a project folder | Set a folder in the Project Configuration window's Location field in the desktop app. |
Code generation works whether or not you are signed in, for either project type, and on every plan. Without signing in you can only choose public packs from the Store and packs on this device (Template store).
What's on the screen
| No. | Name | Description |
|---|---|---|
| 1 | Preview table selector | Shown only when you opened the window for several tables. Chooses which table the preview on the right shows. The template selection applies to all tables. |
| 2 | Install Selected Templates button | Generates the checked templates for every selected table and writes them into the project folder. Available only on the desktop with the Location field set; otherwise hovering over the button shows why. |
| 3 | Download Selected Templates button | Downloads the same result as one ZIP file that keeps the folder structure of the install paths. Works on both the web and the desktop. |
| 4 | Reapply Preview button | Regenerates the result for the table being previewed. Press it after changing the entity settings in the table tab. |
| 5 | Tag filter | Keeps only the templates that have all the selected tags. |
| 6 | Select All checkbox | Checks or clears every template visible in the tree. The number on the right is how many of the visible templates are checked. Checks on templates hidden by the filter are left alone. |
| 7 | Template tree | Each pack assigned to the project is a bold row with its groups and templates under it. Click a template name to see its result on the right. An R mark means the template makes the installed file read-only, and an O mark means it overwrites an existing file. |
| 8 | Install information | Install Path, Alternative Path and whether it will Overwrite. The alternative path is where a template that does not overwrite writes when the file already exists. |
| 9 | Result preview | The generated code. The Template source edit mode option is there only when you can edit that pack (see 'Editing the template source' below). |
| 10 | Copy button, Install This Template button | Copies the previewed result to the clipboard, or installs just this template for every selected table. The install button is on the desktop only. |
- When the window opens it generates only the first table. The other tables are generated when you pick them in the preview selector or when you install or download.
- If a template fails while generating, a notification tells you which table, pack and template. The results of the other templates are still shown.
Preparation: assigning template packs
The packs a project uses are set in the tab. The tab is shown in local projects, and in account projects to the owner or to people with the All Permissions permission.
- Turn on the Enable Code-Generator switch in the tab. In a project that already has packs, the fields below show without the switch.
- On the desktop, use the Search ... button (1) to choose the project folder the generated code is installed into.
- Press the + Add Template Pack button (2) and press the Add button of the pack you want in the Store window (Template store).
- A pack tab (3) appears. If the pack asks for values, fill them in the Template Variables area (6).
- Press the Save button of the Project Configuration window.
- The Location field (1) is required in desktop projects with code generation turned on. If it is empty, saving brings you back to this tab. On the web the field is greyed out and cannot be edited.
- You must assign at least one pack to save. You can add the same pack more than once; each tab keeps its own variable values and per-table settings.
- A mark such as
v1on the pack tab (3) is the pack version this project uses. It is fixed to the latest version at the time you add the pack and does not change on its own when the pack publishes a new version. When a newer version exists, the tab shows an arrow icon and the A newer version is available (v1 → v2). notice, and the Upgrade button moves it up. The×on the tab removes the pack from this project. - A pack whose name line (4) carries the live (my draft) mark is a pack you can edit. It uses your saved working copy rather than a version, so when you edit and save the pack, this project's results change right away. To share it with others, publish the pack (Template packs).
- The Alias field (5) is a name for the pack used only in this project. It tells two copies of the same pack apart.
- The Template Variables area (6) holds the global variables the pack defines (package name, paths and so on). Which fields appear depends on the pack, and you cannot save with a required field empty. A pack without variables shows the This template pack has no modules or variables to configure. notice.
Refining a table's entity settings
Once packs are assigned, the table tab gets a Code Generator tab (Table tab). The entity and field names are made once from the table and column names, and code is generated from the values you set here.
| No. | Name | Description |
|---|---|---|
| 1 | Toolbar | The Generate Source Code... button opens the Generate Source Code - orders and 1 more window for this table. The Reset Entity Settings... button clears the entity settings and rebuilds them with the current rules. The Refresh button reads the current structure from the database again. |
| 2 | Basic Settings area | Values shared by all packs: the entity's Name field, Alias field, Soft Delete switch and Description field. |
| 3 | Per-pack Settings tabs | One tab for each pack assigned to the project. Sets the values that exist only for that pack's language. |
| 4 | Entity area | The entity-level settings the pack defines. Packs without any show the This pack's language profile declares no per-pack entity settings. notice. |
| 5 | Fields grid | One row per column. The Database column group holds database values and cannot be edited. The NAME and COMMENT cells of the common column group are shared by all packs, and values such as the type and META in the pack-only column group on the right apply only to that pack. |
| 6 | Gear icon on the NAME header | Opens the column naming rule window for this table only (Column Renamer). See 'Naming rules' below. |
| 7 | Reset button at the end of a row | Rebuilds the row's name with the rules and returns the common values and this pack's edits to their initial state. |
- Entity settings are saved with the Save button of the table tab. Unsaved changes show a dot next to the Code Generator tab name.
- The initial value of the Alias field is the capital letters of the entity name joined and lowercased. For example,
OrderItembecomesoi. - When you turn on the Soft Delete switch, you choose the deleted-flag column and the deleted-at column. Templates use these to generate code that marks rows instead of deleting them.
- The settings of the Code Generator tab cannot be edited for a table marked for deletion.
Generating source code
- In the explorer, right-click a table and choose the menu. Select several tables and right-click to generate them together in one window. From the Code Generator tab of a table tab, open it with the Generate Source Code... button.
- Check the templates to generate in the tree on the left. Click a template name to see its result on the right.
- Check the result and the Install Path item. With several tables, switch tables with the Preview table selector.
- On the desktop, press the Install Selected Templates button. The files are written under the Location folder and the Source code installed. notification appears.
- On the web, or to get files instead, press the Download Selected Templates button. One table downloads
table-name.zip; several downloadcodegen-number-of-tables-tables.zip.
- If the project has no packs assigned, the menu is greyed out.
- Tables you have never expanded in the tree have their columns read from the database when the window opens. If the database cannot be reached, the Failed to load table metadata (columns). Please check the database connection. notification appears and the code is generated without columns.
- If the tree is empty with the There are no templates to generate. Check that the pack has templates and that the pack version this project uses contains them. notice, the pack version the project uses has no templates. Check that the pack has been published.
- If you install on the desktop with the Location field empty, the Please set the root path of the project where the source code will be installed. notice appears, and confirming opens the Project Configuration window.
- An external AI can also create files with the same packs and settings through the MCP
generate-codetool (AI and MCP, MCP tools).
What happens when you install
The template decides the install path, and the path is always resolved under the Location folder. A .. in the path cannot leave that folder, and a path starting with a drive letter is not installed. Each file is written according to the template's install settings.
| A file at that path | Template setting | What happens |
|---|---|---|
| Does not exist | Creates the folders and writes a new file | |
| Exists | Overwrite (O) | Overwrites it without asking |
| Exists | No overwrite, alternative path set | Writes to the alternative path |
| Exists | No overwrite, no alternative path | Skips it |
| Exists | Insertion marker (needle) | Replaces the marker text in the file with the result. Skips it if the marker is not there |
- A read-only (
R) template makes the written file read-only. When it overwrites, it deletes the existing file and writes a new one. - If the template asks for git staging and the Location folder is a git repository, the written file is
git add-ed.
Editing the template source
If you can edit the pack (a pack with the live (my draft) mark), the preview has the Template source edit mode option above it.
- Choose the Template source edit mode option and edit the template source.
- Press the Apply changes and switch to preview mode button. It is saved to the pack's working copy and the result is generated again.
This edits the pack itself. Results in your other projects that use this pack change too. Other people get the change only after you publish.
Naming rules (Renamer)
The initial entity and field names are made with the connection's naming rules. The rules are set in the Renamer tab of the connection window (Create and edit a connection). Rules are applied in order from the top.
| No. | Name | Description |
|---|---|---|
| 1 | Restore Defaults button | Returns both rule lists to their initial values. Asks first if rules exist. |
| 2 | Table Renamer area | Rules that turn a table name into an entity name. Choose regexp (replace a regular expression with replacement text) or case-format (change the letter case style) in the Renamer Type item, fill in the values and press the Add button. |
| 3 | Rule list | Shown in the order they are applied. Use the arrow buttons to reorder and the trash button to delete. |
| 4 | Column Renamer area | Rules that turn a column name into a field name. Used the same way as for tables. |
| Initial rule | Table name | Column name |
|---|---|---|
| 1 | case-format CAMEL_UPPER (MyName) | case-format CAMEL (myName) |
- The initial rules only change the letter case:
order_itembecomesOrderItemandcustomer_idbecomescustomerId. If your database puts a prefix such astb_before names, add aregexprule (/^tb_/→ empty text) at the top. - Connections created earlier keep their saved rules. If the
regexp/^[^_]*_/rule that removes everything up to the first underscore is still there, a database without prefixes loses the first word and field names collide (order_idandcustomer_idboth becomeid). Delete that rule or press the Restore Defaults button. - Changing the connection's rules does not rename entities already built. To apply the new rules, press the Reset Entity Settings... button of the table tab or the Reset button of a row.
- To treat one table differently, open the Column Renamer window with the gear icon on the NAME header of the field grid. When that table has rules, they are used instead of the connection's column rules. The Load connection settings button copies the connection's rules, and the Save & Apply button saves and rebuilds every field name of this table, overwriting names you edited by hand.
Audit Table tab
The tab is in the settings of projects with code generation turned on, and is visible in local projects and to the owner of an account project or people with the All Permissions permission. It lets templates treat common audit fields such as Created by, Created Date, Modified by and Modified Date separately. Whether these values are used depends on the pack.
| Field | Content |
|---|---|
| Audit Table | The table that holds the audit fields, chosen by connection, schema and table. If it is empty, the tab name shows a warning icon and the Some features may not work if Audit Table is not configured. notice |
| Audit Entity Interface, Immutable Audit Entity Interface | Class names that entities with audit fields inherit from |
| Field Names For Creation, Field Names For Modification | Names treated as the author (Author) and date (Date) fields for creation and modification. Type a name and press the add button |
- Write field names after the naming rules (such as
createdBy), not database column names. - The column information of the chosen table reaches templates only when you generate code for a table on the same connection.
Things to keep in mind
- Installing writes files without asking. Overwrite (
O) templates also overwrite files you edited by hand. Before the first install, download the result with the Download Selected Templates button to check it, or commit the Location folder to git. - Files are skipped when a template that does not overwrite meets an existing file or the insertion marker is not found. In that case, instead of the install-finished notification, a notification shows how many files were not installed and the first reason. If an error occurs while installing, the install stops and an error notification appears.
- On the desktop, templates run on this device while generating code. Use public packs made by others only if you trust them, and read a pack you have not used before in Template packs first.
- Private packs chosen while signed in cannot be read without signing in. A project that uses such a pack cannot generate code when opened without signing in.
- Even when a newer version exists, results are generated from the pinned version. To use the pack author's changes, press the Upgrade button.
Related screens
- Template store: the window for finding and getting packs to add to a project.
- Template packs: the screen for creating, editing and publishing template packs.
- Template syntax: the variables and functions templates use.
- Table tab: the screen with the Code Generator tab.
- Create and edit a connection: the window with the Renamer tab.
- Web and desktop: why the web downloads a ZIP instead of installing.