code: function(req, res, fromMessage) {
              var name = req.params.name;
              var doc  = req.body;
              var id   = this.toId(req.params.id || doc._id);
              if (typeof id === 'undefined' || id === '') {
                  return res.send(400, "invalid id.");
              }
              doc._id   = id;
              doc._time = new Date().getTime();
              var collection = new mongodb.Collection(this.db, name);
              collection.update(
                  { "_id" : id },
                  doc,
                  { safe:true, upsert:true },
                  function(err, n) {
                      if(err) {
                          res.send("Oops!: " + err);
                      } else {
                          if (n==0) {
                              res.send(404, 'Document not found!');
                          } else {
                              var msg = {
                                  method: 'update',
                                  id: doc._id,
                                  time: doc._time,
                                  data: doc
                              };
                              rest.onSuccess(name, msg, fromMessage);
                              res.send(doc);
                          }
                      }
                  }
              );
          }
docs: Update a document