简体   繁体   English

如何在meteor.js(客户端和服务器端)中向图像集合添加描述

[英]How to add description to Image collection in meteor.js ( client side & server side)

I tried in client side 我在客户端尝试过

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

got this error 得到这个错误

​cfs_data-man.js:241 Uncaught Error: DataMan constructor received data that it doesn't support(…) cfs_data-man.js:241未捕获的错误:DataMan构造函数收到了不支持的数据(...)


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

and got this error: 并得到此错误:

collection.js:395 Uncaught errorClass {error: 403, reason: "Not permitted. Untrusted code may only update documents by ID.", details: undefined, message: "Not permitted. Untrusted code may only update documents by ID. [403]", errorType: "Meteor.Error"} collection.js:395未捕获的errorClass {错误:403,原因:“不允许。不受信任的代码只能按ID更新文档。”,详细信息:未定义,消息:“不允许。不受信任的代码只能按ID更新文档。[403 ]“,errorType:” Meteor.Error“}}

assuming you're using CollectionFS, when you insert an image save the _id and then update the document by _id 假设您使用的是CollectionFS,则在插入图像时保存_id,然后通过_id更新文档

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM