Skip to main content

Query Builder Interface

Overview: Query Builder

The Docwize query builder is located in the ‘New’ Module, under ‘Custom Fields.’ This lists created views, as well as provides the place for users to create new queries to build new views.

workflow-builder

'Query Builder' button

'Virtual Views' dialog

When users navigate to the 'Query Builder' section, they encounter the 'Virtual Views' dialog.

workflow-builder

'Virtual Views' dialog

FieldDescription
Create New ViewNavigates to the Query Lab canvas.
(Various names)List of names of created views.

The Query Lab

When users click on 'Create New View', they are directed to the Query Lab. Queries are built in the Query Lab's canvas.

Query Lab canvas

The Query Lab canvas

query-builder

Query Builder: An example query

The Query Lab has four main sections.

Left-hand Section

The left-hand panel has the following tabs:

TabDescription
Custom FieldsLists all available Custom Fields to drag onto the canvas.
TablesLists available system tables.
ViewsLists available system views.
Virtual ViewsLists existing virtual views that can be used as a data source.
FunctionsLists available query functions that can be dragged onto the canvas.
CTEsLists Common Table Expressions (CTEs) defined for the current query.

A Search box at the top filters across all tabs. Each item has a drag handle to pull it onto the canvas.

Top Bar

FieldDescription
Section labelOptionally name the current section of the query.
Save SectionSaves the current section label. Enabled once a label is entered.
PanelsToggles which panels are visible: Sources (left panel), Results (bottom panel), Query (right JSON panel).
Ctrl+K / Command PaletteOpens a command palette for quick actions.

Upper Central Section

This is the query builder canvas. Users can select items from the lefthand section to drag into the canvas. Fields that are dragged and dropped appear as a node.

workflow-builder

Example: Node

FieldDescription
Enables users to link nodes as they build a complex query.
Includes the column in the select.
DescriptionThe column name. Double-clicking the field allows the column to be renamed.

There are certain fields in a node which are standard:

FieldDescription
OwnIDUnique ID in the table/view.
EntityidUsually represents a document ID.
Entitytype“D” for Document.
EntrydateDate the row was inserted.
EntrypersonUser ID of the user who did the insert.
entrybatchidUUID unique to a batch insert.

Bottom Central Section

FieldDescription
Configure QueryShows the configuration tabs for the current query.
ResultsShows query results after running ‘Test Query’.
ColumnsColumn descriptions for the output query.
ConditionsEnables users to apply static and runtime filters.
GroupingEnables users to apply grouping and aggregations.
SettingsAdditional query-level settings.

When viewing the 'Results' view, users have access to the following:

FieldDescription
Select AllFetch all rows.
Page SizeBatch size for pagination.
No/no rowsTotal rows in the query.
Query TimeTime taken for query to execute.

Right-hand Section

FieldDescription
Allows users to connect to external databases.
Loads the backend representation of a query (in JSON) for confirmation and/or editing.
Uses the jsonlogic query as the source instead of the diagram.
This will autoformat edits to JSON.
Assists in fixing query errors.
Test QueryEnables users to run the query to preview results.
Save DatasourcePrompts the pop-up dialog for a user to save the created datasource.

How to Build a Query

StepDescription
1Select the relevant field(s) and drag them onto the Query Lab canvas, where they convert to nodes.
2Make the relevant row(s) visible on the selected nodes.
3Optional: link rows across nodes.
4Click on ‘Test Query’ and navigate to the bottom central section to confirm what is populated. Adjust if needed.
5NOTE: remember to click on ‘Set as Source’ once editing is complete.
6Click on ‘Save Datasource’ and input a name.