-
Notifications
You must be signed in to change notification settings - Fork 3
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
Support for other types of ids #1
base: master
Are you sure you want to change the base?
Conversation
Hi @surfdude75 thanks for your contribution. I understand your concern. |
store.js
Outdated
@@ -88,17 +88,23 @@ class MongoStore extends Store { | |||
* @memberOf MongoStore | |||
*/ | |||
removeById(req) { | |||
var id | |||
try { | |||
id = this.ObjectID(req.id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of check is really bad. We can't trust in that an exception is thrown. Please check the format via regex and swap it out in a separate function to avoid duplicate code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is even better
var mongodb = require("mongodb"),
objectid = mongodb.BSONPure.ObjectID;
console.log(objectid.isValid('53fbf4615c3b9f41c381b6a3'));
Hi @StarpTech I hope it is as you requested. Let me know if it is necessary any other adjustment. Thanks. |
Hi @surfdude75 you cant use https://stackoverflow.com/a/25497438/1893773 ? |
I have a legacy mongo database where not all ids are of type ObjectId.
It would be great if the plugin could try do not use ObjectId if the id is not compatible with the ObjectID.
Thanks and congrats for you great work.