Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we set cursor as a session variable?

I tried to set a cursor as a session variable looks like it is not working.

Anyone has idea about it ??

My Code:

 Meteor.call('apiresult',function(e,result)
    {                                               
    console.log(result);
    Session.set("object",result)                                                                                                        
    }); 

//getting variable
 var abc=Session.get("object");
return abc.skimlinksProductAPI.numFound;        

looks like it's not working

like image 542
Sasikanth Avatar asked Feb 17 '14 06:02

Sasikanth


1 Answers

Cursors can actually be stored in Session... sometimes. open the leaderboard app and try this in the browser console:

> Session.set('mycursor', Players.find());
undefined
> Session.get('mycursor')
LocalCollection.Cursor {collection: LocalCollection, selector_f: function, sort_f: null, skip: undefined, limit: undefined…}
> Session.get('mycursor').fetch()
[Object, Object, Object, Object, Object]

Now download the code of the leaderboard example app, use the latest Meteor, and do the same thing in the browser console. You might get:

enter image description here

The moral of the story seems to be, don't store cursors in session variables. Store the Minimongo selector and options (sort, fields etc.) instead as objects.

like image 140
Dan Dascalescu Avatar answered Sep 28 '22 07:09

Dan Dascalescu