I understand that new Meteor.Collection( null ) is for a local collection that you do not want to publish. You can still publish it, but you will have to use the "added", "deleted" and "modified" publishing functions to indicate which collection on the client receives the data. The client will need to create a named collection to receive the data, but all db methods, such as “delete” or “update”, will be erroneous because they do not exist on the server.
On the server, new Meteor.Collection( 'someName', {connection: null} ) also exists only in memory, but can be used in the publish function in the same way as the collection supported by db. A client collection that receives data is created using new Meteor.Collection( 'someName' ) as usual, and the client will not be able to find out that this collection is only in the server’s memory .
On the client, I think that 'null'-named and' null'-connection are both ways to receive collections that cannot receive / send data from / to the server.
Some discussion here .
update: Collections on the server with {connection: null} do not receive methods configured for client access. These methods can be configured by temporarily creating a connection to collect and define methods. As below:
//server js var serverOnly = new Meteor.Collection( 'serverOnly', {connection: null} ); serverOnly._connection = Meteor.server; serverOnly._defineMutationMethods(); serverOnly._connection = null;
You still need to use allow / deny rules for the collection to allow client methods to work. If you find that you are using this hack, you should comment on the pull request, which makes these methods available by default .
user728291
source share