Skip to content

Commit 75fdf72

Browse files
committed
Updating query() to sql() in nodejs rest examples
1 parent 0f25499 commit 75fdf72

File tree

2 files changed

+6
-6
lines changed
  • samples/features/json/todo-app/nodejs-express4-rest-api

2 files changed

+6
-6
lines changed

samples/features/json/todo-app/nodejs-express4-rest-api/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var tediousExpress = require('express4-tedious');
55

66
var app = express();
77
app.use(function (req, res, next) {
8-
req.query = tediousExpress(req, config.get('connection'));
8+
req.sql = tediousExpress(req, config.get('connection'));
99
next();
1010
});
1111

samples/features/json/todo-app/nodejs-express4-rest-api/routes/todo.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ var TYPES = require('tedious').TYPES;
44
/* GET task listing. */
55
router.get('/', function (req, res) {
66

7-
req.query("select * from todo for json path")
7+
req.sql("select * from todo for json path")
88
.into(res, '[]');
99

1010
});
1111

1212
/* GET single task. */
1313
router.get('/:id', function (req, res) {
1414

15-
req.query("select * from todo where id = @id for json path, without_array_wrapper")
15+
req.sql("select * from todo where id = @id for json path, without_array_wrapper")
1616
.param('id', req.params.id, TYPES.Int)
1717
.into(res, '{}');
1818

@@ -21,7 +21,7 @@ router.get('/:id', function (req, res) {
2121
/* POST create task. */
2222
router.post('/', function (req, res) {
2323

24-
req.query("exec createTodo @todo")
24+
req.sql("exec createTodo @todo")
2525
.param('todo', req.body, TYPES.NVarChar)
2626
.exec(res);
2727

@@ -30,7 +30,7 @@ router.post('/', function (req, res) {
3030
/* PUT update task. */
3131
router.put('/:id', function (req, res) {
3232

33-
req.query("exec updateTodo @id, @todo")
33+
req.sql("exec updateTodo @id, @todo")
3434
.param('id', req.params.id, TYPES.Int)
3535
.param('todo', req.body, TYPES.NVarChar)
3636
.exec(res);
@@ -40,7 +40,7 @@ router.put('/:id', function (req, res) {
4040
/* DELETE single task. */
4141
router.delete('/:id', function (req, res) {
4242

43-
req.query("delete from todo where id = @id")
43+
req.sql("delete from todo where id = @id")
4444
.param('id', req.params.id, TYPES.Int)
4545
.exec(res);
4646

0 commit comments

Comments
 (0)