You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I notice that the name property is reserved when trying to do an update but not when trying to do an insert.
Here's an example of what I mean:
let insertEntry = createTable.then(
function (data) {
//return a promise (will automatically not wrap in another promise) thanks to JS awesomeness
//if entry exists - will overwrite
return dynasty
.table('calvinTable')
.insert({
id: '1',
name: 'calvin'
});
}
// don't have an error handler here because the 'then' above took care of it
// really we should be using catch instead of supplying a success and error handler
);
let queryEntryThatWasJustInserted = insertEntry.then(
function (data) { //data is unwrapped promise
//return a promise (will automatically not wrap in another promise)
console.log('Item was inserted successfully');
return dynasty
.table('calvinTable')
.find({hash: "1"});
},
function (err) {
//uh oh previous step had a problem
}
);
After that I try to update the entry that I just inserted
let updateAfterQuery = queryResults.then(
function (data) {
//return a promise (will automatically not wrap in another promise)
return dynasty
.table('calvinTable')
.update('1', {
name: 'calvin2',
scala: 'isawesome'
});
}
);
let updateResults = updateAfterQuery.then(
function (data) { //data is unwrapped promise
console.log('updated:');
console.log(data);
},
function (err) {
console.log("Uh oh, that didn't work");
console.log(err);
}
);
I get a okay for the table insert
Item was inserted successfully
The results are in:
{ name: 'calvin', id: '1' }
But I get a validation exception on the update
Uh oh, that didn't work
{ [ValidationException: Invalid UpdateExpression: Attribute name is a reserved keyword; reserved keyword: name]
cause:
{ [ValidationException: Invalid UpdateExpression: Attribute name is a reserved keyword; reserved keyword: name]
message: 'Invalid UpdateExpression: Attribute name is a reserved keyword; reserved keyword: name',
code: 'ValidationException',
time: Mon Sep 28 2015 21:28:17 GMT-0400 (Eastern Daylight Time),
statusCode: 400,
retryable: false,
retryDelay: 0 },
isOperational: true,
code: 'ValidationException',
time: Mon Sep 28 2015 21:28:17 GMT-0400 (Eastern Daylight Time),
statusCode: 400,
retryable: false,
retryDelay: 0 }
The text was updated successfully, but these errors were encountered:
We should add a check in Dynasty if you try to provide any object on insert or update that includes one of those reserved words and return an error so it doesn't go through to Amazon.
Hey Victor,
I notice that the name property is reserved when trying to do an update but not when trying to do an insert.
Here's an example of what I mean:
After that I try to update the entry that I just inserted
I get a okay for the table insert
But I get a validation exception on the update
The text was updated successfully, but these errors were encountered: