Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 06 08:24
    yasaricli edited #22
  • May 06 08:23
    yasaricli edited #22
  • May 06 08:23
    yasaricli edited #22
  • May 06 08:22
    yasaricli opened #22
  • Jan 13 07:52
    thearabbit closed #21
  • Jan 13 07:52
    thearabbit commented #21
  • Jan 12 14:29
    zimme commented #21
  • Jan 12 14:20
    thearabbit opened #21
  • Jan 25 2018 11:33
    thearabbit commented #20
  • Jan 23 2018 00:47
    thearabbit commented #20
  • Jan 23 2018 00:41
    thearabbit commented #20
  • Jan 21 2018 09:55
    zimme commented #20
  • Jan 21 2018 03:39
    thearabbit edited #20
  • Jan 21 2018 03:33
    thearabbit opened #20
  • Feb 12 2017 14:53
    zimme closed #16
  • Nov 17 2016 18:24
    webmagnets opened #19
  • Jul 14 2016 11:21
    zimme commented #18
  • Jul 14 2016 11:03
    nicooprat opened #18
  • Nov 22 2015 16:37
    jimmiebtlr commented #16
  • Nov 20 2015 06:42
    roelvan commented #16
Samuel Martin
@martinsam
No ?
Simon Fridlund
@zimme
The best way is to store native JavaScript Date objects, which map onto BSON native Date objects.
and if you need to sort it in js later, use moment(doc.createdAt)
and use moment to format the date as you need
for the sorting
Samuel Martin
@martinsam
I don't quite understand
Simon Fridlund
@zimme
The best way to store date/datetimes in mongodb is to store the native javascript date object and not a unixtimestamp
Samuel Martin
@martinsam
Why don't use timestamp in createdAt attributte ?
ok ok
I'm a noob on Meteor
Simon Fridlund
@zimme
it’s ok, and it’s more of a mongodb thing
but if you add mrt:moment package
you can use moment to manipulate the date to get it in a format you want to do the sorting
Samuel Martin
@martinsam
so in publication.js :
Meteor.publish('posts', function() {
return Posts.find({}, {sort: {createdAt: -1}});
});
it's not posisble
ok "moment"
Simon Fridlund
@zimme
hmm that should work
I’ll take a look
Samuel Martin
@martinsam
Not for me
Simon Fridlund
@zimme
aah
Samuel Martin
@martinsam
?
sort timestamp it's easy
sort "Tue Nov 18 2014 23:07:30 GMT+0100 (CET) " string it's hard no ?
Simon Fridlund
@zimme
I believe it’s a limitation with minimongo
it can’t handle sorting on ISO Date’s
Samuel Martin
@martinsam
minimongo > mongo layer for Js ? ok ?
Simon Fridlund
@zimme
minimongo is the client side mongo layer
Samuel Martin
@martinsam
NoooooooOooo
:)
Simon Fridlund
@zimme
but you should be able to do that sort query in a server method
where minimongo isn’t used
Samuel Martin
@martinsam
yes .. in publication.js it's server side ?
ok ..
Samuel Martin
@martinsam
sorry , client side it's ok ..
If I use sort in client side.. behaviors it's correct
sorry
thanks a lot for your patience zimme
Simon Fridlund
@zimme
yeah, i did a bit of reading and only found old issues with date sorting
it should work now and nice that you git it working =)
I also have a softremovable package too if you need that too in the future
=)
but, time for bed now… take care =)
Samuel Martin
@martinsam
Bye..
Nathan Cain
@webmagnets
createdBy puts an id, but updatedBy puts '0'. Is there a way to make it put the correct id?
Simon Fridlund
@zimme
Hmm wierd, are you updating the record in server side code outside of a method? because in that case it will use the system's id which defaults to 0
@webmagnets
Nathan Cain
@webmagnets
That is probably what it is. Thanks.
@zimme
Simon Fridlund
@zimme
Because there is no way of knowing which user initiated the update/insert outside of a method i just input the userid that represents the system, which is configurable too