1234567891011121314151617181920 |
- // Note: not Documents, but this.Documents, because of the editing package (?)
- this.Documents = new Mongo.Collection("documents");
- if (Meteor.isClient) {
- Template.editor.helpers({
- docid: function () {
- let doc = Documents.findOne();
- return doc ? doc._id : undefined;
- }
- });
- }
- if (Meteor.isServer) {
- Meteor.startup(function () {
- // startup code that creates a document in case there isn't one yet.
- if (!Documents.findOne()) {
- Documents.insert({ title: "my new document" });
- }
- });
- }
|