【问题标题】:How to add description to Image collection in meteor.js ( client side & server side)如何在meteor.js(客户端和服务器端)中向图像集合添加描述
【发布时间】:2015-11-20 13:12:43
【问题描述】:

我在客户端试过

Images.insert({art:"some description"},{ _id:this._id});

收到此错误

​cfs_data-man.js:241 未捕获的错误:DataMan 构造函数接收到它不支持的数据(…)


Images.update({art:"some description"},{ _id:"XztX47mZ2EYcjHdMp"});

得到了这个错误:

collection.js:395 Uncaught errorClass {error: 403, reason: "Not allowed. Untrusted code may only update documents by ID.", details: undefined, message: "Not allowed. Untrusted code只能按 ID 更新文档。[403]", errorType: "Meteor.Error"}

【问题讨论】:

  • 切换那些对象,第一是搜索,第二是你更新的内容

标签: javascript image meteor


【解决方案1】:

假设您使用的是 CollectionFS,当您插入图像时保存 _id,然后通过 _id 更新文档

imgId = Images.insert(...);
Images.update({ _id: imgId },{ $set: { description: "my awesome selfie" }});

【讨论】:

猜你喜欢
  • 2013-01-17
  • 2017-04-17
  • 1970-01-01
  • 1970-01-01
  • 2016-01-14
  • 1970-01-01
  • 2018-02-03
  • 2010-11-14
  • 2014-05-27
相关资源
最近更新 更多