A meteor permits an app?

Getting this error in the console when trying to reinstall into the collection:

"failed: access denied. Upplets are not allowed in the limited collection."

The following are valid rules:

if (Meteor.isClient) { Meteor.subscribe('customers'); } customers = Customers if (Meteor.isServer) { Meteor.publish('customers', function() { return customers.find(); }); customers.allow({ insert: function (document) { return true; }, update: function () { return true; }, remove: function () { return true; } }); } 

Here is a more detailed part:

 Customer.prototype.create = function ( name, address, phone, cell, email, website, contact, shipping ) { var attr = { name : name, address : address, phone : phone, cell : cell, email : email, website : website, contact : contact, shipping : shipping }; Customers.upsert( Customers.maybeFindOne( attr )._id, attr ); return new Customer( attr ); }; 
+7
collections meteor upsert
source share
2 answers

This is the choice of the development team .

The proposed solution is to write a method that completes upsert. This causes the server to request the server code while the client code only works to compensate for the delay. Example:

 //shared code Meteor.methods({ customersUpsert: function( id, doc ){ Customers.upsert( id, doc ); } }); //called from client Meteor.call( 'customersUpsert', Customers.maybeFindOne( attr )._id, attr ); 
+8
source share

This is the work I use (using the default function for underlining):

 _upsert: function(selector, document) { if (this.collection.findOne(selector) != null) { this.collection.update(selector, { $set: document }); } else { this.collection.insert(_.defaults({ _id: selector }, document)); } } 

selector is assumed to be an identifier for an object.

+1
source share

All Articles