में एक गैर-मौजूद (शून्य) विशेषता के लिए आप कैसे क्वेरी करते हैं I email
विशेषता सेट नहीं है, जहां सभी आइटम खोजने के लिए एक डायनेमोडीबी तालिका से पूछताछ करने का प्रयास कर रहा हूं। EmailPasswordIndex
नामक एक वैश्विक माध्यमिक सूचकांक तालिका पर मौजूद है जिसमें email
फ़ील्ड शामिल है।DynamoDB
var params = {
"TableName": "Accounts",
"IndexName": "EmailPasswordIndex",
"KeyConditionExpression": "email = NULL",
};
dynamodb.query(params, function(err, data) {
if (err)
console.log(JSON.stringify(err, null, 2));
else
console.log(JSON.stringify(data, null, 2));
});
परिणाम:
{
"message": "Invalid KeyConditionExpression: Attribute name is a reserved keyword; reserved keyword: NULL",
"code": "ValidationException",
"time": "2015-12-18T05:33:00.356Z",
"statusCode": 400,
"retryable": false
}
तालिका परिभाषा:
var params = {
"TableName": "Accounts",
"KeySchema": [
{ "AttributeName": "id", KeyType: "HASH" }, // Randomly generated UUID
],
"AttributeDefinitions": [
{ "AttributeName": "id", AttributeType: "S" },
{ "AttributeName": "email", AttributeType: "S" }, // User e-mail.
{ "AttributeName": "password", AttributeType: "S" }, // Hashed password.
],
"GlobalSecondaryIndexes": [
{
"IndexName": "EmailPasswordIndex",
"ProvisionedThroughput": {
"ReadCapacityUnits": 1,
"WriteCapacityUnits": 1
},
"KeySchema": [
{ "AttributeName": "email", KeyType: "HASH" },
{ "AttributeName": "password", KeyType: "RANGE" },
],
"Projection": { "ProjectionType": "ALL" }
},
],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1
}
};
dynamodb.createTable(params, function(err, data) {
if (err)
console.log(JSON.stringify(err, null, 2));
else
console.log(JSON.stringify(data, null, 2));
});
क्या आप अपनी तालिका और अनुक्रमणिका विशेषता परिभाषाएं प्रदान कर सकते हैं? – mkobit
@mkobit जोड़ा गया, धन्यवाद। –