Uncaught Error: Not permitted. Untrusted code may only update documents by ID. [403]
Uncaught Error: Not permitted. Untrusted code may only update documents by ID. [403]
我有这个错误,但它没有指定哪一行代码有问题。
有什么办法可以缩小我需要关注的代码范围吗?
不确定这是否是相关问题,但是当我提交文档时它应该可以识别我的 user.username
,但是当 html 显示 {{author}}
时它会变成空白。
collection(两个public/服务器的共享文件夹)的代码如下:
var post = _.extend(postAttributes, {
userId: user._id,
author: user.username
});
感谢任何帮助!
更新:
将 UserAccount 代码转移到服务器文件夹后出现新的错误消息。
Exception while simulating the effect of invoking 'postInsert'
"Match error: Unknown key in field message"
您的客户端代码使用非 _id
作为其查询运算符来更新文档。
无法使用这样的查询在客户端上进行更新。不过,您可以在服务器上执行这些操作。
所以如果你在某处有这样的代码,你 运行 它不会抛出你得到的错误:
MyCollection.update({ someName: someValue }, {$set:{something:true}});
你可以这样做:
var doc = MyCollection.findOne({ someName: someValue });
MyCollection.update({ _id: doc._id }, {$set:{something:true}});
您可以在此处明确定义要更新的文档。要查找此代码,您可能需要查找其中包含 .update
并且可以在客户端 运行 的任何内容。
Changes to allow/deny rules
Starting in 0.5.8, client-only code such as event handlers may only update or remove a single document at a time, specified by _id. Method code can still use arbitrary Mongo selectors to manipulate any number of documents at once. To run complex updates from an event handler, just define a method with Meteor.methods and call it from the event handler.
希望对您有所帮助:)
我有这个错误,但它没有指定哪一行代码有问题。 有什么办法可以缩小我需要关注的代码范围吗?
不确定这是否是相关问题,但是当我提交文档时它应该可以识别我的 user.username
,但是当 html 显示 {{author}}
时它会变成空白。
collection(两个public/服务器的共享文件夹)的代码如下:
var post = _.extend(postAttributes, {
userId: user._id,
author: user.username
});
感谢任何帮助!
更新:
将 UserAccount 代码转移到服务器文件夹后出现新的错误消息。
Exception while simulating the effect of invoking 'postInsert'
"Match error: Unknown key in field message"
您的客户端代码使用非 _id
作为其查询运算符来更新文档。
无法使用这样的查询在客户端上进行更新。不过,您可以在服务器上执行这些操作。
所以如果你在某处有这样的代码,你 运行 它不会抛出你得到的错误:
MyCollection.update({ someName: someValue }, {$set:{something:true}});
你可以这样做:
var doc = MyCollection.findOne({ someName: someValue });
MyCollection.update({ _id: doc._id }, {$set:{something:true}});
您可以在此处明确定义要更新的文档。要查找此代码,您可能需要查找其中包含 .update
并且可以在客户端 运行 的任何内容。
Changes to allow/deny rules
Starting in 0.5.8, client-only code such as event handlers may only update or remove a single document at a time, specified by _id. Method code can still use arbitrary Mongo selectors to manipulate any number of documents at once. To run complex updates from an event handler, just define a method with Meteor.methods and call it from the event handler.
希望对您有所帮助:)