From a7b2aeacbc8e91fa0f4f3b2347bb0bef7a857814 Mon Sep 17 00:00:00 2001
From: bertrand <bpinel@ippon.fr>
Date: Thu, 27 Dec 2018 22:25:39 +0100
Subject: [PATCH] Small update to cope with empty attributes not to persist n
 DynamoDB

---
 cloud/lambda-jsonapi-test.js   | 4 +++-
 cloud/lambda/lambda-jsonapi.js | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/cloud/lambda-jsonapi-test.js b/cloud/lambda-jsonapi-test.js
index 5747004..cc2dd34 100644
--- a/cloud/lambda-jsonapi-test.js
+++ b/cloud/lambda-jsonapi-test.js
@@ -169,7 +169,9 @@ function generateRowId(subid) {
       };
       // Adding attributes as column in dynamoDb
       for (var prop in attrs) {
-          content[prop] = attrs[prop];
+          if (attrs[prop] != null && attrs[prop].length>0)
+            // Empty field cannot be persisted
+             content[prop] = attrs[prop];
       }
       // Dealing with relationships if any
       if (relations){
diff --git a/cloud/lambda/lambda-jsonapi.js b/cloud/lambda/lambda-jsonapi.js
index 99b21c4..57264d0 100644
--- a/cloud/lambda/lambda-jsonapi.js
+++ b/cloud/lambda/lambda-jsonapi.js
@@ -160,7 +160,9 @@ function generateRowId(subid) {
       };
       // Adding attributes as column in dynamoDb
       for (var prop in attrs) {
-          content[prop] = attrs[prop];
+        if (attrs[prop] != null && attrs[prop].length>0)
+            // Empty field cannot be persisted
+            content[prop] = attrs[prop];
       }
       // Dealing with relationships if any
       if (relations){
-- 
GitLab