title: in mongo can I insert a record only if it's not already there
body: <p>I'm using immutable objects keyed with a unique hash. My client doesn't know if the object is the database or not. I want to do an insert only if the object does not already exist. </p>
  
  <p>I know I can query and then insert but that involves an extra round trip. </p>
  
  <p>I know I can just insert and generate a duplicate key exception (in my client) but that involves awkward exception processing.</p>
  
  <p>I know I can upsert but that involves database operations that are totally unnecessary.</p>
  
  <p>In sql I'd use a stored procedure server-side.
  But I am not clear how (if at all) the server side javascript would work for this.
  Any suggestions?</p>