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

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -