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
Message from discussion static Method Use

Date: Thu, 8 Nov 2012 11:18:06 -0800 (PST)
From: Eric Ponce <poncee...@gmail.com>
To: geddyjs@googlegroups.com
Message-Id: <bb794ece-0778-45ce-babd-152b55090347@googlegroups.com>
In-Reply-To: <CALvYELA0DCHjDWRooGFJc6XHxwpkEfc6xHLGHi8RwTbG5Yj90g@mail.gmail.com>
References: <defb4cbc-dab4-49ad-9375-c836888e60a2@googlegroups.com>
 <CALvYELA0DCHjDWRooGFJc6XHxwpkEfc6xHLGHi8RwTbG5Yj90g@mail.gmail.com>
Subject: Re: [geddyjs:247] static Method Use
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_79_23943994.1352402287211"

------=_Part_79_23943994.1352402287211
Content-Type: multipart/alternative; 
	boundary="----=_Part_80_8411722.1352402287211"

------=_Part_80_8411722.1352402287211
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

thanks Matthew but your code give me an error:

Event.getFutureEvents =3D (callback) {=20
                                   ^
SyntaxError: Unexpected token {

:O i've tried to solve it but i can't...

El jueves, 8 de noviembre de 2012 19:46:46 UTC+1, Matthew Eernisse escribi=
=C3=B3:
>
> You can't just `return` from an asynchronous function. You'll have to=20
> use a callback, like this:=20
>
> Event.getFutureEvents =3D (callback) {=20
>         var today =3D new Date();=20
>         Event.all({when:{gt: today}},function(err,events){=20
>             //"when" is the Event date=20
>             if (err) { callback(err, null); }=20
>             else {=20
>               callback(null, events);=20
>             }=20
>         });=20
> };=20
>
> On Thu, Nov 8, 2012 at 3:29 AM, Eric Ponce <ponc...@gmail.com<javascript:=
>>=20
> wrote:=20
> > Hi!=20
> >=20
> > I have two models: Articles and Events=20
> > In the index function of Articles Controller, i've tried to do this:=20
> >=20
> > geddy.model.Article.all({},{sort: {createdAt:"desc"}},function(err,=20
> > articles) {=20
> >     self.respond({params: params, articles: articles, events:=20
> > geddy.model.Event.getFutureEvents()});=20
> > });=20
> >=20
> > and in te Event Model=20
> >=20
> > Event.getFutureEvents =3D function () {=20
> > var today =3D new Date();=20
> > Event.all({when:{gt: today}},function(err,events){=20
> >             //"when" is the Event date=20
> >             return events;=20
> >         });=20
> > }=20
> >=20
> > But in the controller I don't recibe anything.=20
> > If I put console.log(events) in the Event Model I can see all events.=
=20
> >=20
> > Can you help me?=20
> > Thanks! :D=20
> >=20
> > --=20
> > The official community discussion group.=20
> > website: geddyjs.org, source: https://github.com/mde/geddy, group:=20
> > https://groups.google.com/d/forum/geddyjs?hl=3Den=20
> >=20
> >=20
>

------=_Part_80_8411722.1352402287211
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

thanks Matthew but your code give me an error:<div><br></div><div><div styl=
e=3D"background-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, =
187); word-wrap: break-word; " class=3D"prettyprint"><code class=3D"prettyp=
rint"><div class=3D"subprettyprint"><font color=3D"#660066"><div class=3D"s=
ubprettyprint">Event.getFutureEvents =3D (callback) {&nbsp;</div><div class=
=3D"subprettyprint">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;^</di=
v><div class=3D"subprettyprint">SyntaxError: Unexpected token {</div></font=
></div></code></div><br>:O i've tried to solve it but i can't...<br><br>El =
jueves, 8 de noviembre de 2012 19:46:46 UTC+1, Matthew Eernisse  escribi=C3=
=B3:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;">You can't just `return` fr=
om an asynchronous function. You'll have to
<br>use a callback, like this:
<br>
<br>Event.getFutureEvents =3D (callback) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var today =3D new Date(=
);
<br>&nbsp; &nbsp; &nbsp; &nbsp; Event.all({when:{gt: today}},function(err,e=
vents){
<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //"when" is the Event date
<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (err) { callback(err, null=
); }
<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else {
<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; callback(null, events)=
;
<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
<br>&nbsp; &nbsp; &nbsp; &nbsp; });
<br>};
<br>
<br>On Thu, Nov 8, 2012 at 3:29 AM, Eric Ponce &lt;<a href=3D"javascript:" =
target=3D"_blank" gdf-obfuscated-mailto=3D"BXXD3DA2L1MJ">ponc...@gmail.com<=
/a>&gt; wrote:
<br>&gt; Hi!
<br>&gt;
<br>&gt; I have two models: Articles and Events
<br>&gt; In the index function of Articles Controller, i've tried to do thi=
s:
<br>&gt;
<br>&gt; geddy.model.Article.all({},{<wbr>sort: {createdAt:"desc"}},functio=
n(<wbr>err,
<br>&gt; articles) {
<br>&gt; &nbsp; &nbsp; self.respond({params: params, articles: articles, ev=
ents:
<br>&gt; geddy.model.Event.<wbr>getFutureEvents()});
<br>&gt; });
<br>&gt;
<br>&gt; and in te Event Model
<br>&gt;
<br>&gt; Event.getFutureEvents =3D function () {
<br>&gt; var today =3D new Date();
<br>&gt; Event.all({when:{gt: today}},function(err,events){
<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //"when" is the Event da=
te
<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return events;
<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; });
<br>&gt; }
<br>&gt;
<br>&gt; But in the controller I don't recibe anything.
<br>&gt; If I put console.log(events) in the Event Model I can see all even=
ts.
<br>&gt;
<br>&gt; Can you help me?
<br>&gt; Thanks! :D
<br>&gt;
<br>&gt; --
<br>&gt; The official community discussion group.
<br>&gt; website: <a href=3D"http://geddyjs.org" target=3D"_blank">geddyjs.=
org</a>, source: <a href=3D"https://github.com/mde/geddy" target=3D"_blank"=
>https://github.com/mde/geddy</a>, group:
<br>&gt; <a href=3D"https://groups.google.com/d/forum/geddyjs?hl=3Den" targ=
et=3D"_blank">https://groups.google.com/d/<wbr>forum/geddyjs?hl=3Den</a>
<br>&gt;
<br>&gt;
<br></blockquote></div>
------=_Part_80_8411722.1352402287211--

------=_Part_79_23943994.1352402287211--