Blame view

server/methods/update/example.js 555 Bytes
36b159afd   Ryan Glover   Add server/method...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  /*
  * Methods: Update - Example
  * Example of a method used for updating a document in the database.
  */
  
  Meteor.methods({
    exampleUpdateMethod: function(argument){
      // Check the argument. Assuming an Object type here.
      check(argument, Object);
  
      // Perform the update.
      try {
        var exampleId = Example.update(argument._id, {
          $set: {
            "someKey": argument.someKey
          }
        });
        return exampleId;
      } catch(exception) {
        // If an error occurs, return it to the client.
        return exception;
      }
    }
  });