Reputation: 1282
Is there any possibility (in Meteor) to get all Session keys and match them with Regex? like
Session.set( /(?:^|\W)word-(\w+)(?!\w)/g , false )
I want set them all to false. But i know only first word in key name, and it is always the same.
Upvotes: 0
Views: 136
Reputation: 4890
Session
is not designed to work with 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. The only difference is that the data from mySession
will be erased after hot code push. This can be fixed by using reload
or amplify
package but it is quite a different story.
Upvotes: 2