Method: Cequel::Record::Callbacks#save

Defined in:
lib/cequel/record/callbacks.rb

#save(options = {}) ⇒ Boolean

Persist the record to the database. If this is a new record, it will be saved using an INSERT statement. If it is an existing record, it will be persisted using a series of ‘UPDATE` and `DELETE` statements which will persist all changes to the database, including atomic collection modifications.

Parameters:

  • options (Options) (defaults to: {})

    options for save

Options Hash (options):

  • :validate (Boolean) — default: true

    whether to run validations before saving

  • :consistency (Symbol) — default: :quorum

    what consistency with which to persist the changes

  • :ttl (Integer)

    time-to-live of the updated rows in seconds

  • :timestamp (Time)

    the writetime to use for the column updates

Returns:

  • (Boolean)

    true if record saved successfully, false if invalid

See Also:



33
34
35
36
37
# File 'lib/cequel/record/callbacks.rb', line 33

def save(options = {})
  connection.batch(options.slice(:consistency)) do
    run_callbacks(:save) { super }
  end
end