This repository was archived by the owner on Apr 17, 2023. It is now read-only.
This repository was 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
Description
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:
Further info
- the handling code in for doDelete() in the backend in fh-sync relies on the uid of the data item to be deleted being the same as the mongo _id in order to be able to delete the entry successfully
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
Metadata
Metadata
Assignees
Labels
No labels