-
Notifications
You must be signed in to change notification settings - Fork 64
Commit 291d972
Support ObjectID in findByFields() (#75)
The `findByFields()` method could not find documents by a given
ObjectID because the `stringToId()` function was only being run when
querying for a field named `_id`. Since any MongoDB field could in
theory contain an ObjectID, this broke queries looking for ObjectIDs in
arbitrary fields. To resolve this, remove the condition testing for the
field name of `_id` and run `stringToId()` on all values. This will
validate whether a given String value is actually in the ObjectID format
before proceeding, so it seems safe to apply everywhere.
Fixes #65 1 parent b40de70 commit 291d972
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | - | ||
72 | + | ||
73 | 73 | | |
74 | 74 | | |
75 | - | ||
75 | + | ||
76 | + | ||
77 | + | ||
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
| |||
0 commit comments