-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autofetch and subqueries (or nested objects) #490
Comments
Does setting cache to false help at all? |
I have the same problem. Using orm with passport and passport-local, when the user logs in initially the account is retrieve correctly (user ->hasmany user_group (joined with user_user_group), user ->hasMany maillist (joined with maillist_user), the user_id is stored in the session. When the user comes back (very next request) the same function is used to load the user but this time both user_group and maillist = undefined. There is something about the order of operations/timing. It seems like maybe whichever call happens first is successful (maybe). Sometimes both work. Setting { cache: false } on the query seems to have improved it (maybe?), but not stopped it completely. This happens using both .find() and .get() methods. I had been running orm 2.1.13 for a long time (2.1.14 made changes to keys/id required model fixes), but last night I went through the process and fixed my models (removing key: true, and leaving just { id: key_name }, but the problem still exists on 2.1.19 I then wrote a small program node program that tried to do the query using both find/get and ran that 50 times in a shell loop, it always succeeded (getting the right number of groups). I then updated the program so that instead of looping in a shell, it looped inside the program. This also seemed to work without issue. However in the node/express environment it will work for one request and fail for the next. Once it does fail the only way to restore it to working seems to be restarting the server (I tried deleting the session to see if that happened, I tried flushall on redis also to see if there was another way to clear the issue). |
I have a page which bootstraps itself with a list of 25 objects prior to making a REST request for the entire list (234 objects in test).
Because I access the same query through two different entry points, I abstract into a function:
This is all working OK (picking the right promise and executing it). The model is
If I access with the call that bootstraps the page with the "limit"" first, the page loads fine. The Model is loaded to the proper depth. However the subsequent rest call comes through (picking the promise without the limit), and doesn't return any of the nested objects (not the first level User, nor the deeper objects).
If I reset the Node server and access through the REST call (picking the promise without the limit), the entire data set is loaded with proper depth.
I have set all my relationships up with the hasOne relationship, out of comfort of having used it that way in previous projects. That said, I plan to investigate the many relationship once I have this working properly. This project has a legacy DB built by offshore contractors with poor names, and mis-labeled fields. Models:
I can post the user model chain if that will help. Here is how the relationships are set up:
Any thoughts?
The text was updated successfully, but these errors were encountered: