const AWS = require("aws-sdk");
AWS.config.update({
region: <<Your Regions>>,
endpoint: <<Your endpoint>>
});
var dynamo = new AWS.DynamoDB();
var params = {
TableName: <<name of your table>>,
Item: {
'PK' : {"S": `<<Your ITEM'S PK>>`},
'SK' : {"S": `<<YOUR ITEM'S SK`},
'RecentLocations': {"L": [ //>>>>>>>>>>>>>> ARRAY OF OBJECTS STARTS HERE!!!!
{ //we start the first value here
"M": { //we specify it is a map/object
"path": {"S": device.oneLocationOnly.path }, //FIRST PROPERTY AND VALUE
"locationArray": { //SECOND PROPERTY, WHICH IS AN ARRAY/LIST
"L": device.recentLocations.locationArray
}
}
}
]}
},
ConditionExpression: "attribute_not_exists(PK)"
};
dynamo.putItem(params, function(err, data) {
if (err) {
console.log("Error", err);
resolve([false, err])
} else {
resolve([true]);
}
});