Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Items not deleting from mongodb when doDelete() called from the sync client #24

Open
damienomurchu opened this issue Jun 29, 2017 · 0 comments

Comments

@damienomurchu
Copy link

damienomurchu commented Jun 29, 2017

Issue

Data items not deleting from collection in mongo after doDelete() is called from the client

Steps to reproduce

  • call doCreate() in the client code to create a data item to sync with the backend & into mongo
  • call doDelete() on that created data item to delete it
  • check data entry in mongodb to confirm failure to delete

A (very rough) set of client & server sync code if needed can be found here to reproduce the issue

Screenshots of issue

Before & after in mongodb collection:
selection_016
selection_017

Further info

    doDelete: function(dataset_id, uid, meta_data, cb) {
      debug(
        '[%s] doDelete :: %s :: meta=%j', dataset_id, uid, meta_data);
      mongo.collection(dataset_id).remove({"_id": convertToObjectId(dataset_id, uid)}, cb);
    },
function convertToObjectId(datasetId, originalId) {
  var newObjectId = originalId;
  if (ObjectID.isValid(originalId)) {
    newObjectId = ObjectID(originalId);
  } else {
    debug('[%s] Invalid objectId value : %s', datasetId, originalId);
  }
  return newObjectId;
}
var ObjectID = require('mongodb').ObjectID;
  • the uid and the mongo _id are usually synchronised by the sync framework to be the same, but this does not seem to be happening, thus the deletion breaks down
  • this issue should affect other operations (such as update/ read a specific entry) to fail also, but have confirmed this yet

@wtrocki @aidenkeating @wei-lee pinging you on this as requested

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant