CeresDB JQ Support

Overview

Wednesday, 7th December 2022

One feature of CeresDB that I found to be quite lacking was the inability to edit data “in-place”. For example, if I wanted to edit a record I would have to perform a GET, edit that data on my machine, and then push it back with a POST.

I could use PUTs and PATCHes to do some edits, but if I wanted to edit specific list elements, or otherwise select/modify the data that becomes more difficult/impossible very quickly

To get around this limitation, I’ve added support for JQ. This looks like:

<some other query> | JQ '<your jq string here>'

This was surprisingly easy to implement in the AQL backing data file (what it uses to pattern match queries) by just adding an entry of:

{
    "JQ": "^JQ STRING$"
}

With that out of the way, we then added a token type of “JQ” that takes a single string argument. We then modified the internal query manager to now keep a previousData variable populated for piped queries. This gives us the ability to use JQ for data selection as well as modification. In addition, if a POST is performed but no data is given, then CeresDB will post the value of previousData so that we can construct a query like:

<some get query> | JQ '<some jq string>' | POST RECORD <database>.<collection>

Finally, we included jq in the Dockerfile so that CeresDB can call out to it in order to perform the JQ processing.

Simple as that we now have support for a widely used JSON query tool in our database system.

Home
Education
Laboratory Experience
Projects
Publications and Presentations
Work Experience
Journal