Comments (12)
How would it be any different than doing the following?
{'status.lastLogin': {$gte: Date.now() }}
I thought about this, but I couldn't see any difference in storing things as native Date objects.
from meteor-user-status.
Technically results can still be the same, there's a discussion thread on meteor-talk too regarding this topic that I participated in. The guys recommended the native Dates too. https://groups.google.com/forum/#!searchin/meteor-talk/storing$20date/meteor-talk/jujlCBRI4X0/vgWJlgp5MEUJ
from meteor-user-status.
Okay, I'm listening. How do comparisons between native Date objects work? Do they still work between different timezones? What is the purpose of the timezone that is stored in the native date?
Why does one person say to store the timezone separately while the other person says the timezone is included in ISODate
?
The other reason I decided to stick with integers is because of the time offset calculated by timesync. I wasn't sure how to do these diff operations with regular dates and it seemed that instantiating new dates constantly (because of the reactive time variables) would be much more inefficient than necessary. Any comments about that?
from meteor-user-status.
One benefit I see so far in the use of storing native dates is its auto conversion to the right timezone on the client side.
So on my meteor server it records as UTC. But when I load my page in Singapore and retrieve the date field stored, it accurately logs as GMT+8 Singapore time.
from meteor-user-status.
Oh and regarding the comment about storing timezone separately I think that's not required. As mentioned above all the dates in the meteor server just need to be stored in UTC. I think by default the *.meteor.com servers I'm using are already preconfigured to output UTC time when you do new Date() on the server side.
from meteor-user-status.
I thought the conversion to the correct timezone is determined by the browser. If I load up the timestamp in a browser as new Date(timestamp)
it will display in local time, no problem.
If there is no need to store the timezone in the ISO Date then it doesn't seem to confer any benefits to using it (other than the mongo aggregation queries in the thread you linked.) The only other benefit that I see is you would get to store the timezone of client-generated timestamps, but that seems like an edge case.
from meteor-user-status.
true. well just a suggestion. cheers.
from meteor-user-status.
We can leave this open and see if anyone else wants to chime in about it. I'm open to the idea.
In my use cases the integer is far more convenient than the dates because I am measuring time differences and don't want to be using Date objects or moment computations unnecessarily. But I'm interested in hearing other use cases.
from meteor-user-status.
ok cool thanks!
from meteor-user-status.
It's always smart to store dates as Date objects. You can always use valueOf() to get the epoch back out and do the same math you're doing now, but when someone calls the value out, it won't just be an integer. It will be a date object. And that's more human, and thus what I think should be done. I agree with @geekyme
from meteor-user-status.
Hi @wraybowling, thanks for pitching in. I don't think anything you said points to an explicit benefit of using Date
objects versus integers, but I'll keep it in mind. I don't see any method as being 'more human' than the other, though.
from meteor-user-status.
Hi @geekyme, new timestamps stored in the database are all native Date
objects now. Let me know if you find any issues in this version.
Old timestamps are not automatically converted; you may want to do that yourself, but I'm not sure it matters because most libraries that use dates accept integers or native Dates interchangeably.
from meteor-user-status.
Related Issues (20)
- Exception in onLogin callback: Error: ID is required HOT 2
- some users are logged in for ages even they went offline long ago HOT 2
- Users go offline immediately/automatically just after logging in HOT 1
- .find({"status.online": true}) doesnt work HOT 2
- Replace jQuery to decrease weight
- status.idle usage
- Changing the 'status' default property name HOT 3
- Cannot login outside Meteor, no Meteor connection.httpHeaders
- Transfer to Meteor-Community-Packages HOT 9
- Remove usage of underscore HOT 3
- UserStatus no longer global HOT 3
- Support for setUserId or manual login
- TravisCI build is failing HOT 2
- Error while starting app HOT 2
- If you're using this package along with Atlas Mongo 5.0, your project will not run on production environment HOT 13
- Not able to install HOT 3
- Not able to create user after adding status to users schema HOT 1
- DB/Container performance issues on new container creation (from this package) HOT 2
- Support for Meteor 3.0 (fiberless) using async HOT 2
- Meteor 3.0 Support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-user-status.