-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added create schema to use database tutorial (#52)
- Loading branch information
1 parent
1814487
commit dae9d8b
Showing
1 changed file
with
5 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,10 @@ const { Client } = require('pg') | |
async function main(args) { | ||
const client = new Client({ connectionString: args.dbUri }); | ||
|
||
const createSchema = `CREATE SCHEMA IF NOT EXISTS demo;` | ||
|
||
const createTable = ` | ||
CREATE TABLE IF NOT EXISTS contacts ( | ||
CREATE TABLE IF NOT EXISTS demo.contacts ( | ||
id serial PRIMARY KEY, | ||
name varchar(50), | ||
email varchar(50), | ||
|
@@ -137,7 +139,7 @@ async function main(args) { | |
|
||
try { | ||
let res = await client.query( | ||
'INSERT INTO contacts(name,email,phone,message) VALUES($1,$2,$3,$4)', | ||
'INSERT INTO demo.contacts(name,email,phone,message) VALUES($1,$2,$3,$4)', | ||
[name, email, phone, message] | ||
); | ||
console.log(res); | ||
|
@@ -243,7 +245,7 @@ with the integrated services, such as the database we are using. | |
For instance, let’s run: | ||
|
||
```bash | ||
ops devel psql sql "SELECT * FROM CONTACTS" | ||
ops devel psql sql "SELECT * FROM demo.CONTACTS" | ||
|
||
[{'id': 1, 'name': 'OpenServerless', 'email': '[email protected]', 'phone': '5551233210', 'message': 'This is awesome!'}] | ||
``` | ||
|