Can we set cursor as a session variable?

后端 未结 2 432
轻奢々
轻奢々 2021-01-12 23:01

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\',f         


        
2条回答
  •  庸人自扰
    2021-01-12 23:12

    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.

提交回复
热议问题