Content-Length: 261865 | pFad | http://github.com/mesqueeb/vuex-easy-firestore/issues/268

2D update(docs) created_at *not* automatically converted · Issue #268 · mesqueeb/vuex-easy-firestore · GitHub
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

update(docs) created_at *not* automatically converted #268

Open
scriptPilot opened this issue Nov 19, 2019 · 6 comments
Open

update(docs) created_at *not* automatically converted #268

scriptPilot opened this issue Nov 19, 2019 · 6 comments

Comments

@scriptPilot
Copy link

First of all thank you for the great piece of code! Some trouble I have ... following the documentation I expect to get an object of items for a collection, where "created_at" is is a date object. But in fact I find only timestamps in the data object. Anything I misunderstood? Latest version in use.

@louisameline
Copy link
Collaborator

louisameline commented Nov 19, 2019

I believe it's not automatic, you have to tell which fields you want converted, see https://mesqueeb.github.io/vuex-easy-firestore/extra-features.html#firestore-timestamp-conversion

As a side note, if you ever want to persist the state locally using vuex-persist for example, I would advise against having a Date object in it (or any other non-flat object, like functions for example), because the state will not be serializable (or maybe not as you'd expect). Better take the habit now to deal with timestamps.

@scriptPilot
Copy link
Author

scriptPilot commented Nov 20, 2019

@louisameline - Thank you for the response. It's ok to work with .toDate() but I thought created_at and updated_at are transformed automatically to a date object before adding them to the local store according the documentation?

@scriptPilot
Copy link
Author

I have tested again. Even if explained in the documentation, the transformation is not done automatically for created_at and updated_at. But it works when I configure it manually as described.

So - is there any reason for that behavior that it's not done by default?

Bildschirmfoto 2019-11-20 um 13 46 35

@louisameline
Copy link
Collaborator

louisameline commented Nov 20, 2019

You're right, I hadn't noticed that.

I'll let @mesqueeb answer if it was his intention, but I must say that in my opinion, if the fields are currently not converted by default, it needs to stay that way, and it's the documentation which needs to be updated. And if they are converted, we should change that in v2 as by default, the state should not be tampered with.
In my experience, I've almost always regretted "automagic" which is supposed to help the user (but it's great to have options you can enable!). I think having a local state identical to the remote state by default is less prone to confusion. And again, the state needs to be serializable for some people.

@scriptPilot
Copy link
Author

Ok, now it's clear to me. So it would be good to have the updated documentation :-)

@mesqueeb mesqueeb changed the title Timestamp not converted to date object update(docs) created_at _not_ automatically converted Nov 25, 2019
@mesqueeb mesqueeb changed the title update(docs) created_at _not_ automatically converted update(docs) created_at *not* automatically converted Nov 25, 2019
@mesqueeb
Copy link
Owner

@scriptPilot It fell through the cracks 😆 I'll update the docs.


After about two years of open source, I finally got accepted for Github Sponsors!

💜 github.com/sponsors/mesqueeb 💜

A little about me:

  • I love open-source
  • 6 months ago I got a son, and am trying to be an awesome father 😅
  • I'm doing freelance work here and there as my main job

If anyone was helped with vuex-easy-firestore, I'd greatly appreciate any support!

BTW, donations get's paid DOUBLE by GitHub! (they're alchemists... 🦾)

Going forward 👨🏼‍💻

  • I got great plans for the future of vuex-easy-firestore going above and beyond!! Look forward to it!!
  • On to many more years of open-sourcing! 🎉

@mesqueeb mesqueeb reopened this Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/mesqueeb/vuex-easy-firestore/issues/268

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy