Connection Strings are an easy way to configure your application to connect to a SurrealDB instance. They are stored in the appsettings.json
file and can be used to configure the SurrealDbClient
.
In general, it is known as a best practice to:
appsettings.Development.json
,Keys | Description | Aliases | |
---|---|---|---|
Endpoint required | The database endpoint to connect to. | Server | |
Namespace optional | Switches to a specific namespace. | NS | |
Database optional | Switches to a specific database. | DB | |
Username optional | Username used to have root access. | User | |
Password optional | Password used to have root access. | Pass | |
Token optional | Token (JWT) used to have user access. | ||
NamingPolicy optional | Naming policy used to interact with the database. |
Here is a couple of examples of Connection Strings:
Server=http://127.0.0.1:8000;Namespace=test;Database=test;Username=root;Password=root
Endpoint=http://127.0.0.1:8000;NS=test;DB=test;User=root;Pass=root
Endpoint=http://127.0.0.1:8000;NS=test;DB=test;User=root;Pass=root;NamingPolicy=SnakeCaseLower