Sha256: 9665591841a3cd1329c0962a80baa6b98df00c0728aae390d1d7fdbcaba989fe
Contents?: true
Size: 1.13 KB
Versions: 7
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module ROM module Mongo # Mongo specific relation extensions class Relation < ROM::Relation adapter :mongo schema_class ROM::Mongo::Schema option :output_schema, default: -> { schema.to_output_hash } forward :find, :sort, :limit, :skip # @api private def self.view_methods super + [:by_pk] end # Returns relation restricted by _id # # @param id [BSON::ObjectId] Document's PK value # # @return [ROM::Mongo::Relation] # # @api public auto_curry def by_pk(id) find(_id: id) end # Single purpose aggregation operations # Difines count for dataset # # @return [Integer] The total count of documents # # @api public def count dataset.count end # Difines distinct for dataset # # @param [Symbol] attribute The document field name # # @return [Array<String>] The collection of uniq values by field name # # @api public def distinct(attribute) dataset.distinct(attribute) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems