質問編集履歴

6

文章の修正

2018/04/04 07:02

投稿

ryo_274
ryo_274

スコア7

test CHANGED
File without changes
test CHANGED
@@ -82,4 +82,4 @@
82
82
 
83
83
  Node.js 6.10
84
84
 
85
- node-postgres 7.0 https://node-postgres.com/
85
+ [node-postgres 7.0](https://node-postgres.com/)

5

文章の修正

2018/04/04 07:02

投稿

ryo_274
ryo_274

スコア7

test CHANGED
File without changes
test CHANGED
@@ -82,4 +82,4 @@
82
82
 
83
83
  Node.js 6.10
84
84
 
85
- node-postgres 7.0
85
+ node-postgres 7.0 https://node-postgres.com/

4

文章の修正

2018/04/04 07:01

投稿

ryo_274
ryo_274

スコア7

test CHANGED
File without changes
test CHANGED
@@ -58,6 +58,26 @@
58
58
 
59
59
  ```
60
60
 
61
+ ### 試したこと
62
+
63
+ thisを使用する
64
+
65
+ ```Node.js
66
+
67
+ let id = 0;
68
+
69
+ client.query("SQL文", (err, res) => {
70
+
71
+ if (err) throw err;
72
+
73
+ this.id = res.rows[0].id;
74
+
75
+ });
76
+
77
+ ```
78
+
79
+
80
+
61
81
  ### 補足情報
62
82
 
63
83
  Node.js 6.10

3

文章の修正

2018/04/04 07:00

投稿

ryo_274
ryo_274

スコア7

test CHANGED
File without changes
test CHANGED
@@ -58,24 +58,6 @@
58
58
 
59
59
  ```
60
60
 
61
- ### 試したこと
62
-
63
- thisを使う
64
-
65
- ```Node.js
66
-
67
- let id = 0;
68
-
69
- client.query(sql, (err, res) => {
70
-
71
- if (err) throw err;
72
-
73
- this.id = res.rows[0].id;
74
-
75
- });
76
-
77
- ```
78
-
79
61
  ### 補足情報
80
62
 
81
63
  Node.js 6.10

2

文章の修正

2018/04/04 06:53

投稿

ryo_274
ryo_274

スコア7

test CHANGED
File without changes
test CHANGED
@@ -3,6 +3,8 @@
3
3
  Node.jsでnode-postgresを使用してDB接続を行っているのですが、
4
4
 
5
5
  client.query()のcallback関数の値をclient.query()の外のidに代入したいです。
6
+
7
+ callback関数を使用しない方法などでも構いません。
6
8
 
7
9
 
8
10
 

1

文章の修正

2018/04/04 05:33

投稿

ryo_274
ryo_274

スコア7

test CHANGED
@@ -1 +1 @@
1
- client.query()戻り値を渡したい
1
+ Node.jsでPostgreSQL結果callback関数の外の変数に渡したい
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Node.jsでnode-postgresを使用してDB接続を行っているのですが、
4
4
 
5
- client.query()の戻り値をclient.query()の外のidに代入したいです。
5
+ client.query()のcallback関数の値をclient.query()の外のidに代入したいです。
6
6
 
7
7
 
8
8