我们可以将游标设置为会话变量吗? [英] Can we set cursor as a session variable?
问题描述
我试图将光标设置为会话变量,看起来它不起作用。
任何人都有这个想法?
我的代码:
Meteor.call('apiresult',函数(e,结果)
{
console.log(result);
Session.set(object,result)
});
//获取变量
var abc = Session.get(object);
返回abc.skimlinksProductAPI.numFound;
看起来无法正常工作
游标可以实际存储在 Session
...中。打开( sort
, fields
等)而不是对象。
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
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:
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.
这篇关于我们可以将游标设置为会话变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!