textcircle.js 528 B

123456789101112131415161718192021
  1. // Note: not Documents, but this.Documents, because of the editing package (?)
  2. this.Documents = new Mongo.Collection("documents");
  3. if (Meteor.isClient) {
  4. Template.editor.helpers({
  5. docid: function () {
  6. let doc = Documents.findOne();
  7. return doc ? doc._id : undefined;
  8. }
  9. });
  10. }
  11. if (Meteor.isServer) {
  12. Meteor.startup(function () {
  13. // startup code that creates a document in case there isn't one yet.
  14. if (!Documents.findOne()) {
  15. Documents.insert({ title: "my new document" });
  16. }
  17. });
  18. }