You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my project when a user sign in the first time I create the user object with all of the necessary fields in database with bellow code
exportdefaultclassUserextendsAdapters.TypeORM.Models.User.model{// You can extend the options in a model but you should not remove the base// properties or change the order of the built-in options on the constructorconstructor(name,email,image,emailVerified){super(name,email,image,emailVerified);this.score=0;this.name="";this.lastname="";this.balance=0;this.followers=[];}
which works great and it gets saved in db (Mongodb). but it doesnt get updated fields in db when I call the useSession in my code, It only gets the default values which was in the constructor, for example when I update user score to 10 in db, useSession shows the default values for score which is 0(in the constructor)
but the moment I add the User schemas it starts to fetch those values as well which is great and works fine
now when I update a value in db session fetches that value in page transition with nextjs Link(or tab transition) which means if for example followers array has 1 million items in it, it will get refetched! and this will have a huge impact on performance(If I am wrong correct me)
I want your guys advice that what should I do?
1- Something that comes to my mind is to delete the User schema which means(at least I think but I am not sure) that the other fields dont get refetched and I get the only default fields in user like id image email and get all the other fields on demand with query
2- on Sign in fetch all the user fields from db and create the user object and then add it with context provider to the root of my app so it doesnt get refetched all the time
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi guys, Thank you for this awesome work.
In my project when a user sign in the first time I create the user object with all of the necessary fields in database with bellow code
which works great and it gets saved in db (Mongodb). but it doesnt get updated fields in db when I call the useSession in my code, It only gets the default values which was in the constructor, for example when I update user score to 10 in db, useSession shows the default values for score which is 0(in the constructor)
but the moment I add the User schemas it starts to fetch those values as well which is great and works fine
now when I update a value in db session fetches that value in page transition with nextjs Link(or tab transition) which means if for example followers array has 1 million items in it, it will get refetched! and this will have a huge impact on performance(If I am wrong correct me)
I want your guys advice that what should I do?
1- Something that comes to my mind is to delete the User schema which means(at least I think but I am not sure) that the other fields dont get refetched and I get the only default fields in user like id image email and get all the other fields on demand with query
2- on Sign in fetch all the user fields from db and create the user object and then add it with context provider to the root of my app so it doesnt get refetched all the time
Beta Was this translation helpful? Give feedback.
All reactions