main.js 707 B

123456789101112131415161718192021222324252627282930
  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. });