More actions
PostgreSQL is a popular and widely-used SQL relational database used for projects of any size. Since it's used so often, Nest runs an instance of Postgres that you can use without having to spin up a whole new instance that could use a lot of resources.
How to use Nest Postgres
Nest Postgres is just a simple instance of PostgreSQL 16 that you can access with your Nest username and password. To launch the Postgres client, you can simply run:
psql
and you'll enter the interactive Postgres shell where you can run SQL like normal. Since Nest Postgres is publicly accessible, you can also connect to it from any other machine, including wherever your apps may run, such as Vercel!
When you're just using the psql
client on Nest, you don't need to specify your username and password, but if you're connecting to Postgres over a network, then you will need to authenticate. Your username and password will be the same username and password that you use for Nest!
Databases
By default, a Postgres database is created for you, with your Nest username as the database name. You can connect to your database by running the following in the Postgres client:
\c <username>;
If you'd like to create new databases, no worries! You can create a new database with the Nest CLI, by running
nest db create <name>
The Nest CLI will create a new database for you with your Nest username prefixed to it - for example, if your Nest username was orpheus
and you ran nest db create slackbot
, the new database would be named orpheus_slackbot
.