How to seed a database with insecure and autopublish removed?

Hi, I feel like I understand the concept of pub/sub’s roles when removing insecure and autopublish packages but I am having difficulty keeping the data in the database. It appears that the information is sent to be inserted but rejected.

Please see this gist: https://gist.github.com/josephdburdick/62c776f163676406529b

What do I need to do? I don’t want to bootstrap my app insecure, I want to build as I go with fake data (until I populate it myself manually).

Having removed insecure and autopublish, you make sure:

  1. No data is published to the client (autopublish)
  2. You cannot directly insert from the client unless allowed by allow/deny rules (insecure)

Since you already allow through your allow rules, you are actually populating your database with your insert statements. I don’t know what Factory.create() does and assume it does a proper insert.

The reason you are not able to see them, if that is the case, is that you are not publishing that data from your database on the server to the client.

For that, you need to set up proper publish and subscribe methods.

Something like this would help you get started:

if (Meteor.isServer) {
  Meteor.publish('allNetworks', function(){
    return Networks.find();
  });
}

if (Meteor.isClient) {
  Meteor.subscribe('allNetworks');
}
1 Like

Thank you. It turned out that I had settings in my controller that should have been in my iron-router route. Thanks for the reply though, you pointed me in the right direction once I got around the router issue.