title: How to use Meteor Upsert
body: <p>Having a bit of trouble getting my Meteor upsert function working. I am fairly (200 lines of code) new, and I'm having a bit of trouble. </p>
  
  <p>The collection keeps on having additional rows inserted, rather than just updating. I spend the past 30 minutes googling, but I can't find any examples I can understand.</p>
  
  <p>Here's my code:</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>Values.upsert(
      {
        // Selector
        source: "SourceOne",
        currency: "USD"
      },
      {
        // Modifier
        value: res.data['data']['last']['value'],
        time: Date.now(),
      }
    );
  </code></pre>
  
  <p>I've also tried</p>
  
  <pre class="lang-js prettyprint-override"><code>if(Values.find(
        {},{fields: {'source':"SourceOne", 'currency': "USD"}}
      )) {
      Values.update(
        {
          source: "SourceOne", 
          currency: "USD"
        },
        {
          value: res.data['data']['last']['value'],
          time: Date.now()
        }
      );
    } else {
      console.log('blah');
      Values.insert({
        source: "SourceOne", 
        currency: "USD",
        value: res.data['data']['last']['value'],
        time: Date.now()
      });
    }
  </code></pre>
  
  <p>And still can't seem to figure it out.</p>