Sha256: 3af5f42209cacc76d17b641f2b4386f940f0fa011003fd1738e07fa40223e967

Contents?: true

Size: 778 Bytes

Versions: 3

Compression:

Stored size: 778 Bytes

Contents

module MongoHQClient
  class Collection
    include Commons
    include HTTP

    def documents
      json = get("databases/#{database}/collections/#{name}/documents")

      documents = []

      json.each do |doc|
        documents << Document.new(json:doc)
      end

      documents
    end

    def document(id)
      json = get("databases/#{database}/collections/#{name}/documents/#{id}")

      Document.new(json: json)
    end

    def indexes
      json = get("databases/#{database}/collections/#{name}/indexes")

      indexes = []

      json.each do |index|
        indexes << Index.new(json: index)
      end

      indexes
    end

    protected
    def database
      raise "Invalid database" unless @params[:database]
      @params[:database]
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongohq-client-0.0.4 lib/mongohq-client/collection.rb
mongohq-client-0.0.3 lib/mongohq-client/collection.rb
mongohq-client-0.0.2 lib/mongohq-client/collection.rb