By Corgi
Promises and async/await somehow don’t work as I’m coding them. I must (1) connect to db, (2) read collections into arrays, then (3) use data in arrays, IN THAT ORDER. I have not figured out how to force MongoDB + Node.js + JavaScript to do that. It keeps trying to access collections before the db is really connected, and to use data in the arrays before they are really loaded from the collections.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
No idea if anyone can help you here but IMO it’s all about the logic within your code, a few conditionals should help you achieve this.
If DB connection = True then read the collection (select * from your table where date between etc.) > collection dict If collection dict > 1 then use the data in arrays[your stuff in here] else wait (add some logic flags in here) else throw error message (‘Can't connect’)
Don’t rely too much on my logic but this could be the big picture, there’s more needed to make it usable.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.