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.

How to do OR statements??? Docs are completely empty unfortunately

See original GitHub issue

Summary:

How to use the .or() statement? I’ve also checked the mongoose docs

Code sample:

query('ownerId').eq(a).or().eq(b)

query('ownerId').eq(a).or({ownerId: a}).or({ownerId: b})

Current output and behavior:

Invalid Query state: %s must follow query(), where() or filter()

Expected output and behavior:

Be able to or the query

Environment:

Operating System: Operating System Version: Node.js version (node -v): NPM version: (npm -v): Dynamoose version: 1.11.1

Type (select 1):

  • Bug report
  • Feature suggestion
  • Question
  • Other suggestion
  • Something not listed here

Other:

  • I have read through the Dynamoose documentation before posting this issue
  • I have searched through the GitHub issues (including closed issues) and pull requests to ensure this issue has not already been raised before
  • I have searched the internet and Stack Overflow to ensure this issue hasn’t been raised or answered before
  • I have tested the code provided and am confident it doesn’t work as intended
  • I have ensured that all of my plugins that I’m using with Dynamoose are listed above
  • I have filled out all fields above
  • I am running the latest version of Dynamoose

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
fishcharliecommented, Apr 6, 2020

@cupcakearmy

Looks like I solved it.

My error was that was using the query and not scan builder.

basically changing

SomeModel.query('ownerId').in(memberIds).exec() // Nope

to

SomeModel.scan('ownerId').in(memberIds).exec() // Yaas

Couple things here. It’s highly discouraged to do Scan’s in DynamoDB, since it has to search through every document you have. At scale this is not good in terms of performance at all. Of course, you did run into the big requirement about Query’s, you must query for where the hashKey = something. You can’t do an OR for that hashKey without doing multiple Query’s.

Without knowing more about your data structure I can’t really help give any suggestions for how to restructure your data. But chances are you might want to change your data structure so the performance is better.


On a side note. The reason I’m replying to this closed issue is that in Dynamoose v2, I just added support for OR statements to Scan, Query & Conditionals along with groups. However if you want to keep using Scan, using in is probably the easiest for your use case.

However, as I said above, I’d consider rethinking how you think about your data. Checkout this video for more info on that: https://youtu.be/DIQVJqiSUkE.

0reactions
cupcakearmycommented, Apr 6, 2020

Thanks for the response. Switched to Google cloud though and I will never go back to crap AWS xD

Read more comments on GitHub >

github_iconTop Results From Across the Web

Word file corrupted - has gone blank but still displays word count
The first thing you'll want to do is make a copy so that any further fiddling doesn't get your text further disguised. In...
Read more >
Opening Word Documents Shows a Blank Screen
Workaround 1 · Click on File > Options · Go to Add-ins · Under 'Manage' select 'COM Add-ins' and click 'Go…' image.png ·...
Read more >
Focus on content with the new Pageless option in Google Docs
But in February 2022, Google Docs announced a new pageless option for Google Docs, which removes both the empty space around the page...
Read more >
Troubleshoot Google Docs, Sheets, Slides & Forms error ...
If you get an error message such as "Something went wrong. Reload" or "Unable to load file" preventing you from making edits on...
Read more >
6 Solutions on Folder Shows Empty But Files Are There ...
If you encounter a problem that the folder shows empty but files are there on Windows 10/11, no worries!! This post will walk...
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