Module | Sequel::Model::DatasetMethods
In: | lib/sequel/model/base.rb

Dataset methods are methods that the model class extends its dataset with in the call to set_dataset.

### Methods

destroy to_hash

### Attributes

model | [RW] | The model class associated with this dataset

### Public Instance methods

destroy()

Destroy each row in the dataset by instantiating it and then calling destroy on the resulting model object. This isn‘t as fast as deleting the dataset, which does a single SQL call, but this runs any destroy hooks on each object in the dataset.

[Source]

          # File lib/sequel/model/base.rb, line 1106
    1106:       def destroy
    1107:         @db.transaction{all{|r| r.destroy}.length}
    1108:       end

to_hash(key_column=nil, value_column=nil)

This allows you to call to_hash without any arguments, which will result in a hash with the primary key value being the key and the model object being the value.

[Source]

          # File lib/sequel/model/base.rb, line 1113
    1113:       def to_hash(key_column=nil, value_column=nil)
    1114:         if key_column
    1115:           super
    1116:         else
    1117:           raise(Sequel::Error, "No primary key for model") unless model and pk = model.primary_key
    1118:           super(pk, value_column)
    1119:         end
    1120:       end

[Validate]