v0.7.0
Menu

#Connection strings

Both the ferrite-db package and the desktop viewer connect with a ferrite:// string. It is a client-side format only: the server knows nothing about it, and it exists so a client has one string to take.

ferrite://[user:password@]host[:port][/database][?options]
ferrite://127.0.0.1
ferrite://alice:[email protected]:7878/shop?tls=true&caFile=/etc/ferrite/ca.pem
ferrite://127.0.0.1/shop?token=<token>
ferrite://[::1]:7878/shop?format=binary

#Parts

part meaning
host defaults to 127.0.0.1. Write IPv6 as [::1]:7878
port defaults to 7878
path the database. After login the client sends use for it. Without one, the viewer lists the databases to pick from, and the package needs client.db(name) or a database option
user:password@ log in as a user with SCRAM-SHA-256. The password never crosses the connection. Percent-encode @, : and / in it

#Options

option meaning
token= log in with the server's admin token instead of a user. Not together with user
tls=true use TLS. The server is TLS 1.3 only
caFile= PEM file of the authority to trust, for a self-signed or private-CA server certificate. Without it, the system roots are used
certFile=, keyFile= a client certificate, for a server that has FERRITE_TLS_CLIENT_CA. They go together
tlsInsecure=true skip checking the server certificate. For testing only
format=json or format=binary which wire format. json is the default

The tls options only mean something with tls=true.

With a token or a password, use tls=true on anything that is not loopback. Without it the token and the data travel as plain text.

#Package-only options

The ferrite-db package also reads poolSize, pipeline, connectTimeout, timeout, keepAlive, idleTimeout, tagFloats, maxLine and setDefault, in the string or as an object. The viewer ignores them. See Node and Bun.

#Examples

import { connect } from "ferrite-db";

const client = await connect("ferrite://alice:[email protected]/shop?tls=true");

A password with special characters:

ferrite://boss:p%40ss%[email protected]/shop

Mutual TLS with a token:

ferrite://db.example.com/shop?tls=true&caFile=/etc/ferrite/ca.pem&certFile=client.pem&keyFile=client.key&token=<token>

See TLS for the server side, and authentication for users and tokens.