User Guide

Installation

To use this client, you need a compatible TypeDB Server running. You can find install instructions in the TypeDB Documentation.

Compatibility table:

TypeDBClient.jlTypeDBTypeDB ClusterJulia
0.1.02.4->=1.6
0.1.12.5, 2.6->=1.6

Inside the Julia REPL, type ] to enter the Pkg REPL mode then run

pkg> add TypeDBClient

Quickstart

First make sure the TypeDB server is running. See Start the TypeDB Server section.

In the Julia REPL or in your source code:

using TypeDBClient

You have two choices:

  • If you are only interested in working interactively, you can use the more simplified API. An example for this is:
using TypeDBClient: dbconnect, open, read, write, match, insert, commit, create_database

# Connecting the client to TypeDB
dbconnect("127.0.0.1") do client

    # Create a database
    create_database(client, "my-typedb")
    # Opening a session
    open(client, "my-typedb") do session
        # Open a write transaction
        write(session) do transaction
            # Insert a record using TypeQL
            insert(transaction, raw"insert $_ isa person;")
            # Commit the transaction
            commit(transaction)
        end
        # Open a read session
        read(session) do transaction
            # Make a match request with a TypeQL string
            answers = match(transaction, raw"match $p isa person;")
        end
    end
end

For working with data using TypeQL, please refer to the syntax on TypeQL Documentation

  • If you want the full stack at your fingertips, then you can use the following commands:
using TypeDBClient

# Only for convenience reasons, you can write the full name if you want
g = TypeDBClient

# Create a client
client = g.CoreClient("127.0.0.1",1729)

# Create a database called typedb if the database wasn't already created by you previously.
g.create_database(client, "typedb")

#=
    Open a session to write in the schema section of the database.
    Be careful if you work with a schema session. No more sessions are allowed
    until you close this session. Closing a session is mandatory. Don't forget this
    at the end of your work.
=#
session = g.CoreSession(client, "typedb" , g.Proto.Session_Type.SCHEMA, request_timeout=Inf)

# Open a write transaction
transaction = g.transaction(session, g.Proto.Transaction_Type.WRITE)

#=
    Make a query in the database
    The result of this query will be a vector of ConceptMap.
    From there you can access the data as you want.
=#
results = g.match(transaction, "match \$x sub thing;")

# If you want to work further in the session, go ahead, else close the session.
close(session)

If you want to use the full potential of the client you should read the documentation of the API functions. There you will find all you need for working programmatically in the database. Otherwise, it is even possible to get equal results using TypeQL.

User API