You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
788 B
Markdown
35 lines
788 B
Markdown
5 years ago
|
# postgresql-socket-url
|
||
|
|
||
|
Generates a well-formed URL for a given PostgreSQL domain socket path and database name. Useful when you want to use a database driver (like `pg`) to connect to PostgreSQL through a Unix domain socket.
|
||
|
|
||
|
## Example
|
||
|
|
||
|
```js
|
||
|
"use strict";
|
||
|
|
||
|
const postgresqlSocketUrl = require("postgresql-socket-url");
|
||
|
|
||
|
let url = postgresqlSocketUrl({
|
||
|
socketPath: "/tmp",
|
||
|
database: "myproject"
|
||
|
});
|
||
|
|
||
|
console.log(url); // socket:/tmp?db=myproject
|
||
|
```
|
||
|
|
||
|
## API
|
||
|
|
||
|
### postgresqlSocketUrl(options)
|
||
|
|
||
|
Generates the URL to connect to.
|
||
|
|
||
|
- __options:__
|
||
|
- __socketPath:__ The path of the folder that __contains__ the PostgreSQL socket. *Not* the path of the socket itself.
|
||
|
- __database:__ The name of the database to connect to.
|
||
|
|
||
|
## Changelog
|
||
|
|
||
|
### 1.0.0 (September 14, 2019)
|
||
|
|
||
|
Initial release.
|