非同期であるため、コールバック関数でドキュメントを処理する必要があります。あなたがやろうとしているのはこれだと思います。
IDでドキュメントを取得します
// docId is the _id passed from the client
Techs.findById(docId, function(err, doc) {
// This code executes after we've returned from MongoDB with the answer
// Now you can either updated it some code like this
doc.title = 'new title';
// Then after you've updated you need to call the save() function
doc.save();
// Now send the response to the client
response.end(doc); // this will send the JSON of the doc to the client
});
また
フィールドで1つのドキュメントを検索します(タイプ:「iphone」)
// Find a document based on a query
Techs.findOne({type: 'iphone' }, function(err, doc) {
// This code executes after we've returned from MongoDB with the answer
// Now you can either updated it some code like this
doc.title = 'new title';
// Then after you've updated you need to call the save() function
doc.save();
// Now send the response to the client
response.end(doc); // this will send the JSON of the doc to the client
});