Over the Network
Configuring an over-the-network instance and connecting to it
Last updated
Was this helpful?
Configuring an over-the-network instance and connecting to it
Last updated
Was this helpful?
When you install tydb locally (npm i tydb
) or globally (npm i -g tydb
), you'll get a CLI tool to run a network exposed instance of TyDB.
Before you run the command, you'll have to setup a configuration file, written in typescript, with a name that ends with .tydb.ts
like this:
To run such TyDB in production you may need to have some kind of process manager, this is not included to give you more freedom and choice over which process manager you'd like to have, here's an example of how to do it using PM2 as an example.
After installation of TyDB and PM2 and creating your configs file (e.g. tydb.config.js
) run this command:
If you have TyDB globally installed, then run npm root -g
to locate the directory in which TyDB is installed. The bin.js
file is found in dist
directory, so your pm2 command may look like this:
After running the pm2 start command, run the log command
There shouldn't be any errors being logged. And to make sure that your database is being served over the network, head to your browser and type in the host name with the port (e.g. http://localhost:3000
), and you should be greeted with a response like this one:
And when adding the database namespace to the URL (e.g. http://localhost:3000/ns1
) and you should see a message like this one:
Each property in the databases
field represents a database, the key of this property (e.g. ns1
) is the namespace that you would use to connect to this specific database. The value of this property is the database configuration. .
TyDB uses framework to serve the database over the network. Hence the fastify field contains configurations related to fastify.
.
.
.
Finally, to connect to the database that you've created above, use the connection URL as described in as the ref
.