question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FindOne() does not honor multiple where()

See original GitHub issue

Node 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:open
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
grd2345commented, Aug 7, 2019

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.

1reaction
navicsteincommented, Aug 6, 2019

Hi @grd2345 honestly the word findOne means find only one 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 to FindOne() 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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found