title: DynamoDb with ConditionExpression
body: <p>Consider the following DynamoDb table:</p>
  
  <p>TableName: <code>foo-bar</code>
  HashKey: <code>Foo, str</code>
  RangeKey: <code>Bar, str</code>
  Name: <code>Baz, str</code></p>
  
  <p>Now with the <a href="https://github.com/ryanfitz/vogels" rel="nofollow">vogels API</a> I'm trying to insert an item with a HashKey, a new RangeKey, and a Name.</p>
  
  <p>But the Name must not exist for the given HashKey: </p>
  
  <p>So we define the table layout for the vogels API:</p>
  
  <pre><code>var foobar = vogels.define("foo-bar", {
      tableName: "foo-bar",
      hashKey: "foo",
      rangeKey: "bar",
      schema: {
          "foo": Joi.string(),
          "bar": Joi.string(),
          "name": Joi.string()
      }
  });
  </code></pre>
  
  <p>And then the insertion of the item: </p>
  
  <pre><code>var itemToInsert = { foo: "foo", bar: "bar2", name: "TEST" };
  
  var params = {};
  params.ConditionExpression = "foo &lt;&gt; :foo AND name &lt;&gt; :name";
  params.ExpressionAttributeValues = {
      ":foo": itemToInsert.foo,
      ":name": itemToInsert.name
  };
  
  foobar
      .create(itemToInsert, params, function(error, data) {
          if(error) {
              console.log(error);
          }
          else {
              console.log(data);
          }
  });
  </code></pre>
  
  <p>There is already an item in the table with the following values: <code>{foo: "foo", bar: "bar", name: "TEST" }</code></p>
  
  <p>So I'm expecting the system to give me an error since there is already a match because of the <code>ConditionExpression</code>, however the item is inserted without a problem. Is this not possible with DynamoDb? </p>
  
  <p>Notice that it doesn't matter whether I use vogels or directly the aws-sdk, both of them have the same problem, i.e. the item is inserted and the <code>ConditionExpression</code> doesn't block the insert.</p>