Module: Torque::PostgreSQL::Relation::DistinctOn
- Included in:
- Torque::PostgreSQL::Relation
- Defined in:
- lib/torque/postgresql/relation/distinct_on.rb
Instance Method Summary collapse
-
#distinct_on(*value) ⇒ Object
Specifies whether the records should be unique or not by a given set of fields.
-
#distinct_on!(*value) ⇒ Object
Like #distinct_on, but modifies relation in place.
-
#distinct_on_values ⇒ Object
:nodoc:.
-
#distinct_on_values=(value) ⇒ Object
:nodoc:.
Instance Method Details
#distinct_on(*value) ⇒ Object
Specifies whether the records should be unique or not by a given set of fields. For example:
User.distinct_on(:name)
# Returns 1 record per distinct name
User.distinct_on(:name, :email)
# Returns 1 record per distinct name and email
User.distinct_on(false)
# You can also remove the uniqueness
24 25 26 |
# File 'lib/torque/postgresql/relation/distinct_on.rb', line 24 def distinct_on(*value) spawn.distinct_on!(*value) end |
#distinct_on!(*value) ⇒ Object
Like #distinct_on, but modifies relation in place.
29 30 31 32 |
# File 'lib/torque/postgresql/relation/distinct_on.rb', line 29 def distinct_on!(*value) self.distinct_on_values = value self end |
#distinct_on_values ⇒ Object
:nodoc:
9 |
# File 'lib/torque/postgresql/relation/distinct_on.rb', line 9 def distinct_on_values; get_value(:distinct_on); end |
#distinct_on_values=(value) ⇒ Object
:nodoc:
11 |
# File 'lib/torque/postgresql/relation/distinct_on.rb', line 11 def distinct_on_values=(value); set_value(:distinct_on, value); end |