Meteor: Best way to create a new document in a collection before visiting a route? -
every time user visits specific route, i'd new document created act "draft" user edit until decide publish it.
another way think want redirect user new page displaying document after successful insert of document.
when phrase that, think i've answered own question. in case call meteor method creates , inserts new document, in callback method use iron-router's router.go method redirect url using new _id parameter. there better way?
it's bad idea collection created automatically upon visiting route. happen if user visit route unintentionally?
nevertheless, can achieve inserting document on publish function , created upon meteor.subscribe.
meteor.publish('test-draft', function(options){ var _id = test.insert({a: 'b'}); return test.find({_id: _id}) })
Comments
Post a Comment