Skip to content
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

Fix data lose that was happening due to creating post #666

Merged
merged 3 commits into from
Jul 5, 2023

Conversation

Palakkgoyal
Copy link
Contributor

@Palakkgoyal Palakkgoyal commented Jul 5, 2023

This PR fixes issue no. #649
It was somewhat tricky to find but, very crucial to implement. Everything was working fine with the user collection but, whenever the user create a new post his/her data in the collection got replaced with an array that contain just a ref for a single post.
Actually, there was a mistake in updating the doc. Instead of updating doc, it was getting replaced by the set function.

Copy link
Owner

@narayan954 narayan954 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's still a problem in this I believe. If an old user who doesn't exists in the users collection uploads a post, then this would crash and he won't be able to create a post. Actually this function was set to update initially and I found this error and suggested him to somehow upsert the post(create user document if it doesn't exists and add the post ther). Unfortunately there's this error as well. Need to think of a solution. Checking if user exists first and then uploading a post seems costly and slow

@narayan954 narayan954 linked an issue Jul 5, 2023 that may be closed by this pull request
@Palakkgoyal
Copy link
Contributor Author

Yes, its very costly to check everytime for the user. I think as the website is still under development we should remove all users and apply users collection correctly. As currently here are only developers and not real users.
What do you think?

@narayan954
Copy link
Owner

narayan954 commented Jul 5, 2023

Yes, its very costly to check everytime for the user. I think as the website is still under development we should remove all users and apply users collection correctly. As currently here are only developers and not real users. What do you think?

you're correct! I was thinking the same. We should start fresh! I'm changing the db :)

Copy link
Owner

@narayan954 narayan954 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

@narayan954 narayan954 merged commit d56204d into narayan954:master Jul 5, 2023
4 of 6 checks passed
@Palakkgoyal Palakkgoyal deleted the dataLoseBug branch July 6, 2023 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

User data lost whenever user create a post
2 participants