FindOne() does not honor multiple where()
See original GitHub issueNode version: v8.16.0 Sails version (sails): 1.2.3 ORM hook version (sails-hook-orm): 2.1.1 Sockets hook version (sails-hook-sockets): 1.5.5 Grunt hook version (sails-hook-grunt): 1.0.8 DB adapter & version (e.g. sails-mysql@5.55.5): 1.0.2
I am in the process of migrating to version 1 and their is a breaking change that I did not see on the migration documents. This used to work in the prior version.
Agreement.findOne() .where({id: agreementId}) .where({locationId: employee.currentLocation.id})
Now this fails with
More than one matching record found for .findOne()
:
I stepped through the adapter code and it ignores all .where() except the last where, which is an issue.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Findone for multiple queries not working mongoose [duplicate]
You can't access book_id directly as it is inside an array. Try this: model.
Read more >Mongoose findOne with Multiple Conditions - ObjectRocket
findOne() with multiple conditions. Go through all the documents in the details collection. The first and third document has the same values for ......
Read more >Euler and Hamiltonian Paths and Circuits - Lumen Learning
All the highlighted vertices have odd degree. Since there are more than two vertices with odd degree, there are no Euler paths or...
Read more >Spring Data Couchbase - Reference Documentation
Earlier versions of Couchbase are not available because SDK 2 and 3 cannot live on the same ... The method getCouchbaseOperations() has also...
Read more >VA FileMan Programmer Manual: FIND^DIC( ) - Hardhats.Org
NOTE: The Finder does NOT honor the Special Lookup or Post-Lookup Action nodes defined in the ... You cannot specify word processing or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
thanks, yes, I refactored to not use chain-able where clauses anymore. just wanted to inform that version prior to v1 allowed chainable where clauses and not anymore.
Thanks for everything.
Hi @grd2345 honestly the word
findOne
means find onlyone
document in the DB, with a specific attribute that matches only one record [eg -> id], if multiple records was matched sails would panic, which means that duplicates records was entered twice somehow, this is not actually related toFindOne() honoring multiple where()
clause. rewriting your code with one.where({ id: agreementId, locationId: employee.currentLocation.id })
will still throw this error, this is a common problem i’ve faced with sails in the past, but a work around is dope!