Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 2.89 KB

queries.md

File metadata and controls

24 lines (17 loc) · 2.89 KB

Queries

https://github.com/RoamJS/roamjs-components/blob/main/src/queries

Utility functions for interacting with the Roam Research database are provided in the https://github.com/RoamJS/roamjs-components/blob/main/src/queries directory. These functions facilitate various operations, including retrieving and manipulating data.

  • Datalog Compilation: The compileDatalog function in https://github.com/RoamJS/roamjs-components/blob/main/src/queries/compileDatalog.ts compiles Datalog-related constructs into string representations. This includes data patterns, source variables, constants, variables, function expressions, predicate expressions, rule expressions, and different types of clauses (not, or, and, not-join, or-join).

  • Attribute Retrieval: The getAttributeValueByBlockAndName function in https://github.com/RoamJS/roamjs-components/blob/main/src/queries/getAttributeValueByBlockAndName.ts retrieves the value of an attribute associated with a specific block. It uses a Datalog query to find the block with the given attribute name and parent UID, then extracts and returns the attribute value.

  • Utility Functions:

    • isTagOnPage in https://github.com/RoamJS/roamjs-components/blob/main/src/queries/isTagOnPage.ts checks if a given tag is present on a specific page. It normalizes the tag and title, then uses a Datalog query to determine if the tag exists on the page.
    • normalizePageTitle in https://github.com/RoamJS/roamjs-components/blob/main/src/queries/normalizePageTitle.ts normalizes a page title by replacing backslashes and double quotes with their escaped counterparts.

These utility functions are essential for efficiently interacting with the Roam Research database, enabling complex queries and data manipulations. For more detailed information on specific operations, refer to the respective sections on