Module: TinyDyno::Expected

Extended by:
ActiveSupport::Concern
Included in:
DocumentComposition
Defined in:
lib/tiny_dyno/expected.rb

Instance Method Summary collapse

Instance Method Details

#request_as_new_record(request) ⇒ Object

insert Expected clause, which will ensure that INSERTs will only take place if there is no record with that hash key yet



8
9
10
11
12
13
14
15
# File 'lib/tiny_dyno/expected.rb', line 8

def request_as_new_record(request)
  request.merge({
                    expected: {
                        "#{ primary_key[:attribute_name] }": {
                            comparison_operator: 'NULL'
                        }
                    }})
end