Methods
(inner) deleteItem(table, key, callback)
deleteItem - delete an item from the table
Parameters:
Name | Type | Description |
---|---|---|
table |
string | table name |
key |
object | primary key to table entry to update |
callback |
function | callback callback function |
- Source:
Example
var table = 'table-name';
var key = {
username: {
'S': 'steve'
}
};
db.deleteItem(params, function(err, results(){});
(inner) describeTable(table, callback)
describeTable - get table metadata
Parameters:
Name | Type | Description |
---|---|---|
table |
string | table name |
callback |
function | callback function |
- Source:
(inner) getItem(table, key, callback)
getItem - get a single item from the table
Parameters:
Name | Type | Description |
---|---|---|
table |
string | table name |
key |
object | primary key to table entry to retrieve |
callback |
function | callback callback function |
- Source:
Example
var table = 'table-name';
var key = {
username: {
'S': 'steve'
}
};
db.getItem(params, function(err, results(){});
(inner) initialize(regionopt, callback)
initialize dynamodb access
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
region |
string |
<optional> |
"us-west-2" | sets the region of your dynamodb table |
callback |
function | callback function to call when initialization is done (not necessary, this is synchronous) |
- Source:
(inner) putItem(table, key, callback)
putItem - inserts an item into the table
Parameters:
Name | Type | Description |
---|---|---|
table |
string | table name |
key |
object | item to insert |
callback |
function | callback callback function |
- Source:
Example
var table = 'table-name';
var item = {
username: {
'S': data.username
},
createDate: {
'S': new Date().toString()
},
};
var params = {
table: table,
key: item
};
db.putItem(params, function(err,results){});
(inner) query(table, key, callback)
query - query items from the table.
Parameters:
Name | Type | Description |
---|---|---|
table |
string | table name |
key |
object | keys to query |
callback |
function | callback callback function |
- Source:
Example
var table = 'table-name';
var key = {
customerId: {
ComparisonOperator: 'EQ',
AttributeValueList: [{
S: '1455-15412'
}]
}
}
db.query(params, function(err, results(){});
(inner) scan(table, raw, sleep, callback)
scan - scan table
Parameters:
Name | Type | Description |
---|---|---|
table |
string | table name |
raw |
boolean | if true, prevents removing the data types from the response |
sleep |
number | sets a sleep timer between pagination calls |
callback |
function | callback callback function |
- Source:
Example
var table = 'table-name';
db.scan({table: table}, function(err, results(){});
(inner) updateItem(table, key, expression, values, callback)
updateItem - update a single item
Parameters:
Name | Type | Description |
---|---|---|
table |
string | table name |
key |
object | primary key to table entry to update |
expression |
object | update expression |
values |
object | update values |
callback |
function | callback callback function |
- Source:
Example
var table = 'table-name';
var key = {
username: {
'S': params.username
}
};
var expression = "set password = :val1";
var values = {
':val1': {
'S': bcrypt.hashSync(params.newPassword, 8)
},
};
var params = {
table: table,
key: key,
expression: expression,
values: values
};
db.updateItem(params, function(err, results(){});