0

I have a bunch of tables in my app, and I have a view that basically loads all of them via associations, The problem is I end up with something like 100 queries if its not cached. Is there a way just to do 1 query and load the entire database into memory, I tried .includes but it still does queries for .count and other stuff. .entries doesn't seem to work. Any tips and help are greatly apreciated.

My model associations are like so (many>one, one=one):

  • Clients < Projects < Activities = Assignments = Users
  • Assignments < Tasks
4
  • 1
    Could you provide more information about your schema? You wish to load the entire database? This would be all of the tables and all of their associations? Commented May 5, 2016 at 17:12
  • edited the question with more information, yes all the tables, their contents . Formated in a way that make sense, according to their associations Commented May 5, 2016 at 17:19
  • Have you tried nesting your .includes like this answer shows? Commented May 5, 2016 at 17:58
  • I'm curious, what is the reason is you want to load the entire database? Is it perhaps to use as a JSON object on the front-end? Commented May 5, 2016 at 18:01

1 Answer 1

0

Alright, so the thing was: includes were working fine

It's just when you include and run .order or .count it still queries the database for some reason I substituted .count to .size and .order to .sort

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.