TREx and terminusdb-client-js library integration devlog for tutorial

Hey folks, thought I’d ask questions while documenting my challenges and gaps in knowledge after having read through some of the available documentation around getting javascript land integrated with TerminusDB. I think this will be a great way to make sure we address what devs will face in the javascript tutorial, basically what are the gaps and common misunderstandings. I’ll document and ask questions here

Entry 1:
Completed:

  1. Read through a bunch of blog posts (Graph Fundamentals p1-4 etc)
  2. Downloaded and installed terminusdb-bootstrap and terminus-client-js
  3. Did some tutorials and create my db “mnemosyne” (Titan goddess of memory and mother of the 9 muses) in bootstrap
  4. Created an Express server and connected to my db in the bootstrap

Pain Points:

  1. The README.md for terminus-client-js has links to the client documentation and API that don’t work (github.io?) I have a PR out to update them to point to the terminusdb.com hosted docs
  2. The JS client README.md used “my_secret_key” as the key passed in as an option to client.connect() and that doesn’t work if you just created a database but didn’t change the password. The PR to update the README.md adds this as well
  3. Do I call client.connect() each time before a query or just once? What are the structure of responses? Is there a way to go from JSON-LD transmitted over the wire to JSON or javascript objects?
  4. This should’ve been dead simple and shown as an example. My use case is below and in SQL/MongoDB/Neo4j this would’ve been a row/json document/node with properties respectively. Pretty simple and I’m sure I’ll figure it out but this is an unfortunate road block this early in the process :frowning:
  5. Do I use client.updateTriples() or client.query() ? The documentation for updateTriples I think is wrong and copied from replaceTriples.

I want to store the following javascript object (let’s call it a “LogEntry” class/object/type):
{logId: "10d-cjfd-vbu", entrydate: "202010061940", content: "hello world"}

Something to take javascript objects or JSON and convert to
simple triples/WOQL/JSON-LD (not sure the interplay yet, but I’m guessing you make WOQL objects using the javascript library and pass them to `client.query() which turns them into JSON-LD and passes that to the DB).

I’m reading about OWL and maybe something like
(“doc:10d-cjfd-vbu”, “type”, “mn:LogEntry”)
(“doc:10d-cjfd-vbu”, “entrydate”, “202010061940”)
(“doc:10d-cjfd-vbu”, “content”, “hello world”)

At this point I thought something that would scare away devs “Man, I want JSON objects stored more easily than creating triples for each property.” and I thought “uh oh, my webapp will be hindered by academics”

No offense guys, just being honest so you can adjust your messaging and approach because you don’t want people to think “Forget it I could model a simple graph faster in xDB” It’s these simple apps that turn out to be huge, and we wanna make it easy.

Right now I think something that takes javascript objects or JSON with an ID field and converts it into OWL triples with the following format:
(id) - (json property name) - (json property value)

Would help dissuade people from thinking “Crap I can’t just pass a javascript object to a method and have it be stored?”

Next Steps:
I’m going through the bank tutorial in more depth to figure out what queries I should write to create the schema and enter the data I need as triples. Also gotta figure out how to use client.query and woql so I can store my simple logentry.

3 Likes

Super! Very useful, thank you :pray: