main.js 818 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Code that is only sent to the server.
  2. // main.js is loaded last:
  3. // http://docs.meteor.com/#/full/structuringyourapp
  4. Meteor.startup(function () {
  5. // Insert a document if there isn't one already.
  6. if (!Documents.findOne()) {
  7. Documents.insert({ title: "my new document" });
  8. }
  9. });
  10. // Publish read access to collections.
  11. // All visible docs.
  12. Meteor.publish("documents", function () {
  13. Meteor._debug("Publishing documents");
  14. return Documents.find({
  15. $or: [
  16. { isPrivate: { $ne: true } },
  17. { owner: this.userId }
  18. ]
  19. });
  20. });
  21. // Users editing docs.
  22. Meteor.publish("editingUsers", function () {
  23. Meteor._debug("Publishing all editingUsers");
  24. return EditingUsers.find();
  25. });
  26. Meteor.publish("comments", function () {
  27. Meteor._debug("Publishing comments");
  28. return Comments.find();
  29. });