Skip to content

Commit

Permalink
fix ids
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasPe committed Oct 25, 2018
1 parent 6810aa7 commit 2a68e92
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ItemDelete/function.json
Expand Up @@ -9,7 +9,7 @@
"methods": [
"delete"
],
"route": "item"
"route": "items/{id}"
},
{
"type": "http",
Expand Down
2 changes: 1 addition & 1 deletion ItemDelete/index.js
Expand Up @@ -6,7 +6,7 @@ const tableName = "mytable";
module.exports = function (context, req) {
context.log('Start ItemDelete');

const id = req.query.id;
const id = req.params.id;
if (id) {
// create a temporary object with PartitionKey & RowKey of the item which should be deleted
var item = { PartitionKey: 'Partition', RowKey: id };
Expand Down
2 changes: 1 addition & 1 deletion ItemUpdate/function.json
Expand Up @@ -9,7 +9,7 @@
"methods": [
"put"
],
"route": "items"
"route": "items/{id}"
},
{
"type": "http",
Expand Down
3 changes: 3 additions & 0 deletions ItemUpdate/index.js
Expand Up @@ -6,10 +6,13 @@ const tableName = "mytable";
module.exports = function (context, req) {
context.log('Start ItemUpdate');

const id = req.params.id;
if (req.body) {

// TODO: Add some object validation logic
const item = req.body;
// Use the ID from the URL for the RowKey
item.RowKey = id;

// Depending on how you want this to behave you can also use tableService.mergeEntity
tableService.replaceEntity(tableName, item, function (error, result, response) {
Expand Down

0 comments on commit 2a68e92

Please sign in to comment.