如何在node.js中转义并将数据保存到simpledb
我正在使用 simpldb 并尝试在 simpledb 中保存 rahul' mehta ,但它给了我以下错误: 代码:
function htmlEscape(text) {
return text.replace(/&/g,'&').
replace(/</g,'<').
replace(/"/g,'"').
replace(/'/g,''');
}
console.log(params.filename);
if (params.filename!=undefined) params.filename=htmlEscape(params.filename);
console.log(sys.inspect(params));
sdb.putItem(domain, params.objectid, params, function( error ) {
});
输出:
rahul' mehta
{
filename: 'rahul' mehta',
}
错误:
{"event":"error","errno":"InvalidQueryExpression","message":"The specified query expression syntax is not valid.","queueno":7}
为什么会出现此错误,我该如何解决它?
I am using simpldb and am trying to save rahul' mehta
in simpledb but it is giving me error below :
Code :
function htmlEscape(text) {
return text.replace(/&/g,'&').
replace(/</g,'<').
replace(/"/g,'"').
replace(/'/g,''');
}
console.log(params.filename);
if (params.filename!=undefined) params.filename=htmlEscape(params.filename);
console.log(sys.inspect(params));
sdb.putItem(domain, params.objectid, params, function( error ) {
});
Output :
rahul' mehta
{
filename: 'rahul' mehta',
}
Error :
{"event":"error","errno":"InvalidQueryExpression","message":"The specified query expression syntax is not valid.","queueno":7}
Why this error is coming , how can i solve it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此错误是因为您尝试运行 Amazon SimpleDB SELECT 查询,并且该查询的语法错误。这可能是因为在查询中 - 属性值 - 必须用单引号打开,即“属性值”,并且如果 - 域名< /strong> -- 和 -- 属性名称 -- 包含任何特殊字符,则必须用锐角符号打开它们,即
域名
或属性名称
。我认为您可以保存rahul' mehta,但是当您尝试获取已保存的属性值时,您会收到此错误。 http://www.sdbexplorer.com/This error is because you are trying to run Amazon SimpleDB SELECT Query and syntax of that query is wrong. This may be because in query -- Attribute Value -- must be unclosed with single quotes i.e. 'Attribute Value', and again if -- Domain Name -- and -- Attribute Name -- contains any special characters then they must be unclosed with acute i.e
Domain Name
ORAttribute Name
. I think you are able to save rahul' mehta but when you are trying to get that saved attribute-value, you are getting this error. http://www.sdbexplorer.com/