From 02d0043f444bd6b5ccdeb32c482bcdc0a67e17b9 Mon Sep 17 00:00:00 2001
From: mcmlxxix <>
Date: Fri, 10 May 2013 18:56:32 +0000
Subject: [PATCH] use JSONdb.remove() method instead of writing undefined when
 deleting a record (removes records completely instead of leaving an empty
 property behind)

---
 exec/load/json-client.js | 2 +-
 exec/load/json-db.js     | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/exec/load/json-client.js b/exec/load/json-client.js
index 4e3201ae6a..3771bf6398 100644
--- a/exec/load/json-client.js
+++ b/exec/load/json-client.js
@@ -296,7 +296,7 @@ function JSONClient(serverAddr,serverPort) {
         this.send({
 			scope:scope,
 			func:"QUERY",
-			oper:"WRITE",
+			oper:"DELETE",
             location:location,
 			data:undefined,
 			lock:lock,
diff --git a/exec/load/json-db.js b/exec/load/json-db.js
index 32d38528c4..af00da9a8c 100644
--- a/exec/load/json-db.js
+++ b/exec/load/json-db.js
@@ -498,9 +498,12 @@ function JSONdb (fileName, scope) {
     /* remove a record from the database (requires WRITE_LOCK) */
     this.remove = function(request,record) {
 		var client = request.client;
+		
 		/* if the requested data does not exist, do nothing */
-		if(record.data === undefined) 
+		if(record.data === undefined || !record.data.hasOwnProperty(record.property)) {
 			return true;
+		}
+		
 		/* if this client has this record locked */
 		else if(record.shadow[record.property]._lock[client.id] && 
 			record.shadow[record.property]._lock[client.id].type == locks.WRITE) {
-- 
GitLab