This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- create a user first. For users and roles see | |
| -- https://www.postgresql.org/docs/9.5/static/sql-createrole.html | |
| CREATE USER readonly_user WITH ENCRYPTED PASSWORD 'shhsecret' NOSUPERUSER NOCREATEDB NOCREATEROLE; | |
| -- then grant the user permission to connect to the database (in this case, db) | |
| GRANT CONNECT ON DATABASE db TO readonly_user; | |
| -- finally, grant permission to the user to select (read) tables in the target schema (in this case public) | |
| GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly_user; | |
| -- turns out that, granting permission to all tables isn't enough, we need grant on sequences too. | |
| -- From https://www.postgresql.org/docs/9.5/static/sql-grant.html: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const mongodb = require('mongodb'); | |
| // MongoDB connection defaults | |
| const OPTION_AUTO_RECONNECT = true; | |
| const OPTION_SOCKET_OPTIONS = { | |
| keepAlive: 1, | |
| connectTimeoutMS: 30000 | |
| }; |