Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
adding default date to model
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
W.S. Hager  
View profile  
 More options Jul 13 2012, 8:36 am
From: "W.S. Hager" <wsha...@gmail.com>
Date: Fri, 13 Jul 2012 14:36:18 +0200
Local: Fri, Jul 13 2012 8:36 am
Subject: adding default date to model

Hi,

When I want to add a default value to the date property in my model, the
date returned is a stale one:

...
dateFormat = require('dateformat');
...
date:{
            type:"string",
            format:"date",
            "default":dateFormat(new Date(),"isoDate")

},

...

The date in the new instance is not the current date but two days ago. When
I restart persvr I get the current one. How can I fix this?

Thanks.

--

W.S. Hager
Lagua Web Solutions
http://lagua.nl


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Hockey  
View profile  
 More options Jul 13 2012, 11:01 pm
From: Ben Hockey <neonstalw...@gmail.com>
Date: Fri, 13 Jul 2012 20:01:53 -0700 (PDT)
Local: Fri, Jul 13 2012 11:01 pm
Subject: Re: adding default date to model

with what you currently have, the dateFormat(new Date(),"isoDate") code is
run once (when your model is defined) and this is why the date in the
instance is old - in fact it will be the same for every instance that gets
the default value.

fortunately, the "default" property can be a function that will be invoked
for every instance that gets the default value.

"default": function () { return dateFormat(new Date(),"isoDate"); }

i believe that should work.

thanks,

ben...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
W.S. Hager  
View profile   Translate to Translated (View Original)
 More options Jul 14 2012, 6:44 am
From: "W.S. Hager" <wsha...@gmail.com>
Date: Sat, 14 Jul 2012 12:44:24 +0200
Local: Sat, Jul 14 2012 6:44 am
Subject: Re: [persevere] Re: adding default date to model

Awesome! Thanks.
 Op 14 jul. 2012 05:01 schreef "Ben Hockey" <neonstalw...@gmail.com> het
volgende:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »