SmallBolt

Description

Neo4j bolt driver for Pharo Smalltalk, based on Seabolt.

Details

Source
GitHub
Dialect
pharo (25% confidence)
Stars
6
Forks
1
Created
July 24, 2020
Updated
Nov. 22, 2025
Topics
neo4j-driver pharo-smalltalk

README excerpt

# SmallBolt

[Neo4j](https://neo4j.com/) bolt driver for Pharo Smalltalk, based on [Seabolt](https://github.com/neo4j-drivers/seabolt).

## Examples

### Simple cypher execution

```smalltalk
client := SbClient new.
client settings password: 'neoneo'.
client connect.
cypher := 'UNWIND range(1, 10) AS n RETURN n'.
result := client transactCypher: cypher.
client release.
result inspect.
```

### Using session manager

```smalltalk
sessionManager := SbClientSessionManager default.
sessionManager standBy: 3 setting: [:settings | settings password: 'neoneo'].
cypher := 'MATCH p = (n:Movie)<-[r]-(m) RETURN p LIMIT 10'.
sessionManager clientDo: [ :cli | 
  result := cli runCypher: cypher.
  Transcript cr; show: result fieldValues.
].
```

### Execute cypher with arguments

```Smalltalk
sessionManager := SbClientSessionManager default.
sessionManager standBy: 3 setting: [:settings | settings password: 'neoneo'].
cypher := 'MATCH (n:Movie) WHERE n.title = $name RETURN n'.
args := {'name'->'The Matrix'} asDictionary.
sessionManager clientDo: [ :cli | 
  result := cli runCypher: cypher arguments: args.
  Transcript cr; show: result firstFieldValues first properties.
].
```

### Execute cypher generated by [SCypher](https://github.com/mumez/SCypher)

```Smalltalk
node := 'n' asCypherIdentifier.
nameParam := 'name' asCypherParameter.
cypher := (CyQuery statements: { 
	CyMatch of: (CyNode name: node label: 'Movie').
	CyWhere of: (CyExpression eq: (node prop: 'title') with: nameParam).
	CyReturn of: node.
}) cypherString.
args := {nameParam identifier -> 'The Matrix'} asDictionary.
sessionManager clientDo: [ :cli | 
  result := cli runCypher: cypher arguments:  args.
  Transcript cr; show: result firstFieldValues first properties.
].

```


## Installation

```smalltalk
Metacello new
  baseline: 'SmallBolt';
  repository: 'github://mumez/SmallBolt/src';
  load.
```

You also need to put a Seabolt shared library (libseabolt).
The latest pre-built libraries are in [shared-libraries](./shared-libraries/) directory.
The libraries tagged with #stable are located at [stable release]([https://github.com/mumez/Smallbolt/releases/stable]). BaselineOfSmallBolt will  automatically download the appropriate library from the [release]([https://github.com/mumez/Smallbolt/releases/stable]) according to the current platform.

## Performance

SmallBolt communicates with Neo4j via efficient Bolt protocol using FFI. Generally, it is about 3 times faster than [Neo4reSt](https://github.com/mumez/Neo4reSt) REST client.

[Neo4reSt](https://github.com/mumez/Neo4reSt) REST client:
```smalltalk
graphDb := N4GraphDb new.
graphDb settings password: 'neoneo'.

[1000 timesRepeat: [ 
cypher := 'MATCH (m:Movie)<-[r]-(n) RETURN m,r,n LIMIT 10'.
resp := graphDb restClient queryByCypher: cypher.
resp result data
]] timeToRun. "=>0:00:00:04.854"
```

SmallBolt:
```smalltalk
client := SbClient new.
client settings password: 'neoneo'.
client connect.

[1000 timesRepeat: [  
cypher := 'MATCH (m:Movie)<-[r]-(n) RETURN m,r,n LIMIT 10'.
result := client runCypher: cypher.	
result fieldValues
]] timeToRun. "=>0:00:00:01.499"
```
← Back to results