Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API bug: DELETE devicestatus and treatsments #4080

Closed
VladislavLasmann opened this issue Nov 20, 2018 · 2 comments
Closed

API bug: DELETE devicestatus and treatsments #4080

VladislavLasmann opened this issue Nov 20, 2018 · 2 comments

Comments

@VladislavLasmann
Copy link

Using the Nightscout-API to delete the types devicestatus and treatsments we noticed that the function remove(_id, fn) doesn't work properly. The delete seems to have no effect.


Treatments:
https://github.com/nightscout/cgm-remote-monitor/blob/master/lib/server/treatments.js
Line: 100

The original code looks like this:
function remove (_id, fn) { api( ).remove({ '_id': new ObjectID(_id) }, fn); ctx.bus.emit('data-received'); }

Our solution:
function remove (_id, fn) { api( ).remove({ '_id': _id }, fn); ctx.bus.emit('data-received'); }

Devicestatus:
https://github.com/nightscout/cgm-remote-monitor/blob/master/lib/server/devicestatus.js
Line: 62

The original code looks like this:
function remove (_id, fn) { var filter; if (_id === '*') { filter = {}; } else { filter = { '_id': new ObjectID(_id) }; } return api( ).remove(filter, fn); }

Our solution:
function remove (_id, fn) { return api( ).remove('_id': _id , fn); }


Using this fix, the delete function works.

@jpcunningh
Copy link
Collaborator

@VladislavLasmann, I believe that would break the ability to delete all of the devicestatus records as used in the admintools.

@jpcunningh
Copy link
Collaborator

#4088 should correct this issue.

I'm not sure why it doesn't work as it was written. I don't believe the PR should cause a different result, but it works and preserves the benefits of using ObjectID and the '*' option for devicestatus.

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

No branches or pull requests

4 participants