Paths & Queries Tutorial
This tutorial builds on the Content Types and Import/Export tutorials to show how to locate and query objects in a Base.
Watch the video above, or follow the step-by-step instructions below.
Launch Content Manager (CMS) App
If not continuing immediately from the Import/Export tutorial, navigate to the presidents in the CMS.
- Launch the Content Manager (CMS) App.
- Click "Presidents" in the folder tree on the left.
Paths (cPath)
Similar to how a file path addresses files in a file system, a cPath addresses objects in a repository.
There are a number of places cPath can be used throughout webCOMAND:
- Title Bar - Click "Edit cPath" () on the right side of the title bar to reveal the cPath Editor.
- Collection Bar Search - Enter cPath in the search to filter objects in the collection.
- API App - Enter cPath to query the repository from a cQuery tab in the API app.
cPath is also used in a number of other places, but those will be covered in other tutorials.
Single Object cPath
A simple cPath is similar to a file path with slash-separated folders and a final filename, except the final element is an object key instead of a filename. For example, the /Bases/Presidents folder contains Presidents that have a Unique/Key Number field, so we can address the first president with:
/Bases/Presidents/"1"
Collection (Multiple Objects) cPath
In addition to referencing a single object, a cPath can also reference a collection of objects.
To reference the collection of all objects in a folder, simply leave off the final object key. For example, to reference all objects in the Presidents folder:
/Bases/Presidents
A cPath can also reference objects with a "filter", which can specify criteria besides a folder or object key. Filters criteria is specified in square brackets. For example, to show all President objects:
[:President]
The square brackets specify a filter, the colon indicates a following Content Type Identifier.
In addition to filtering by content type, field criteria can be specified. For example, to show all President objects with "John" as their first name:
[:President AND Name LIKE "John %"]
Folders and filters can be combined to retrieve only content in a folder that matches the filter:
/Bases/Presidents/[:President AND Name LIKE "John %"]
Queries (cQL)
Similar to how SQL is used to query a database, cQL is used to query a content repository.
cQL can be entered in all of the places cPath was entered above, including the Title Bar, Collection Bar Search and API App.
For example, a collection of all Presidents, no matter what folder they are in, can be retrieved with:
SELECT * FROM President
In cQL, all clauses are optional though, so the SELECT * can be dropped when it is not needed:
FROM President
To restrict results based on certain criteria, use a WHERE clause, similar to SQL:
FROM President WHERE Number>=12 AND Number<=24
To limit results to objects in a specific folder, use the IN clause:
FROM President IN /Bases/Presidents
ORDER BY and LIMIT can be added to a query, similar to SQL:
FROM President IN /Bases/Presidents ORDER BY Number DESC LIMIT 12
cPath & cQL
cQL can be appended to any cPath in curly braces. This is useful for taking advantage of features of cQL that are not available in cPath. For example, add an ORDER BY or LIMIT clause to a cPath.
/Bases/Presidents/[:President]{WHERE Name LIKE "George%" LIMIT 5}
{FROM President}
is a valid query.