我在流星應用程序中有一個任務集合。 我要推從「待辦事項」任務,以「做」和「做」 statuses
Meteor.js在調用Foo.update(id,{conditions})時會移除文檔字段
我已經得到了他們的名單與他們的ID在DOM
創建一個流星方法更新任務,所謂的方法,沒有工作。什麼都沒有發生,任務不會更新。
所以,我試圖調用Task.update方法直接
Meteor.methods({
create : function(json){Task.insert(json);},
update : function(id, conditions){Task.update(id, {$set : conditions});}
});
Template.todo.events({
'click .submit' : function(){
console.log("event called",this._id);
//Meteor.call('update',(this._id, {'status':'doing'}));
Task.update(this._id, {'status':'doing'});
}
});
當Task.update(this._id,{ '地位': '做'});
被調用。集合中的描述字段爲空,只有狀態字段被更新。
Task.update之前
{ "_id" : "er6Rqvdj8P373cPM5", "status" : "doing" , "description" : "work out and eat green chillies"}
後Task.update("er6Rqvdj8P373cPM5",{"status":"done"})
{ "_id" : "er6Rqvdj8P373cPM5", "status" : "done" }
同時呼籲update : function(id, conditions){Task.update(id, {$set : conditions});}
我收到以下錯誤流星日誌
異常而調用方法「更新'MongoError:In有效修改規定:$設置
Exception while invoking method 'update' MongoError: Invalid modifier specified: $set
at Object.Future.wait (/Users/otto/.meteor/tools/275efdf2db/lib/node_modules/fibers/future.js:322:15)
at _Mongo.update (app/packages/mongo-livedata/mongo_driver.js:269:12)
at _.each.Meteor.Collection.(anonymous function) [as update] (app/packages/mongo-livedata/collection.js:354:32)
at Meteor.methods.update (app/alacrity.js:39:45)
at _.extend.protocol_handlers.method.exception (app/packages/livedata/livedata_server.js:593:30)
at _.extend.withValue (app/packages/meteor/dynamics_nodejs.js:31:17)
at app/packages/livedata/livedata_server.js:592:46
at _.extend.withValue (app/packages/meteor/dynamics_nodejs.js:31:17)
at _.extend.protocol_handlers.method (app/packages/livedata/livedata_server.js:591:37)
at _.extend.processMessage.processNext (app/packages/livedata/livedata_server.js:484:43)
- - - - -
at Object.exports.toError (/Users/otto/.meteor/packages/mongo-livedata/405d21f01568c045554ee5b99d2bea88a5249feb/.npm/node_modules/mongodb/lib/mongodb/utils.js:108:11)
at null.<anonymous> (/Users/otto/.meteor/packages/mongo-livedata/405d21f01568c045554ee5b99d2bea88a5249feb/.npm/node_modules/mongodb/lib/mongodb/collection.js:477:24)
at g (events.js:192:14)
at EventEmitter.emit (events.js:126:20)
at Server.Base._callHandler (/Users/otto/.meteor/packages/mongo-livedata/405d21f01568c045554ee5b99d2bea88a5249feb/.npm/node_modules/mongodb/lib/mongodb/connection/base.js:130:25)
at Server.connect.connectionPool.on.server._serverState (/Users/otto/.meteor/packages/mongo-livedata/405d21f01568c045554ee5b99d2bea88a5249feb/.npm/node_modules/mongodb/lib/mongodb/connection/server.js:517:20)
at MongoReply.parseBody (/Users/otto/.meteor/packages/mongo-livedata/405d21f01568c045554ee5b99d2bea88a5249feb/.npm/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:127:5)
at Server.connect.connectionPool.on.server._serverState (/Users/otto/.meteor/packages/mongo-livedata/405d21f01568c045554ee5b99d2bea88a5249feb/.npm/node_modules/mongodb/lib/mongodb/connection/server.js:476:22)
at EventEmitter.emit (events.js:96:17)
at _connect (/Users/otto/.meteor/packages/mongo-livedata/405d21f01568c045554ee5b99d2bea88a5249feb/.npm/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:175:13)
雖然流星文檔說:
// mark my first message as "important"
Messages.update(myMessages[0]._id, {$set: {important: true}});
http://docs.meteor.com/#meteor_user
我這樣做,現在 'Meteor.call( '更新',(字符串(this._id){$設置:{狀態: '做'}} )); 更新:功能(ID,條件){任務。更新(字符串(ID),條件);} 和我得到: '異常而調用方法 '更新' 錯誤:無效改性劑。修飾符必須是一個對象。 at _Mongo.update(app/packages/mongo-livedata /' – qwexar 2013-04-30 10:54:06