[英]Meteor Session.get and Regex
Is there any possibility (in Meteor) to get all Session keys and match them with Regex? (在流星中)是否有可能获取所有会话密钥并将其与Regex匹配? like 喜欢
Session.set( /(?:^|\W)word-(\w+)(?!\w)/g , false )
I want set them all to false. 我想将它们全部设置为false。 But i know only first word in key name, and it is always the same. 但是我只知道键名中的第一个单词,而且总是一样。
Session
is not designed to work with regexp
. Session
不适用于regexp
。 On the other hand you can easily use client-side collections for storing information of this type. 另一方面,您可以轻松地使用客户端集合来存储此类信息。 So 所以
var mySession = new Meteor.Collection(null); // null is important!
mySession.update({key: {$regexp: /* regexp */}}, {$set: {value: false}});
Remember that Collection
is a reactive data-source just like Session
, so this will behave almost identically as Session
in terms of templates rendering. 请记住,就像Session
一样, Collection
是一个反应性数据源,因此就模板渲染而言,它的行为几乎与Session
相同。 The only difference is that the data from mySession
will be erased after hot code push. 唯一的区别是,在热代码推送之后, mySession
中的数据将被擦除。 This can be fixed by using reload
or amplify
package but it is quite a different story. 可以通过使用reload
或amplify
包来解决此问题,但这完全是另一回事了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.