Skip to content
Snippets Groups Projects
Commit 02d0043f authored by mcmlxxix's avatar mcmlxxix
Browse files

use JSONdb.remove() method instead of writing undefined when deleting a record...

use JSONdb.remove() method instead of writing undefined when deleting a record (removes records completely instead of leaving an empty property behind)
parent 41023743
Branches
Tags
No related merge requests found
...@@ -296,7 +296,7 @@ function JSONClient(serverAddr,serverPort) { ...@@ -296,7 +296,7 @@ function JSONClient(serverAddr,serverPort) {
this.send({ this.send({
scope:scope, scope:scope,
func:"QUERY", func:"QUERY",
oper:"WRITE", oper:"DELETE",
location:location, location:location,
data:undefined, data:undefined,
lock:lock, lock:lock,
......
...@@ -498,9 +498,12 @@ function JSONdb (fileName, scope) { ...@@ -498,9 +498,12 @@ function JSONdb (fileName, scope) {
/* remove a record from the database (requires WRITE_LOCK) */ /* remove a record from the database (requires WRITE_LOCK) */
this.remove = function(request,record) { this.remove = function(request,record) {
var client = request.client; var client = request.client;
/* if the requested data does not exist, do nothing */ /* if the requested data does not exist, do nothing */
if(record.data === undefined) if(record.data === undefined || !record.data.hasOwnProperty(record.property)) {
return true; return true;
}
/* if this client has this record locked */ /* if this client has this record locked */
else if(record.shadow[record.property]._lock[client.id] && else if(record.shadow[record.property]._lock[client.id] &&
record.shadow[record.property]._lock[client.id].type == locks.WRITE) { record.shadow[record.property]._lock[client.id].type == locks.WRITE) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment