Sha256: 87be8d0f608626b655a6a35e273636e7c48078c7e7da51b14b8b59b742a08fd6

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

module Unified

  module ChangeStreamOperations

    def create_change_stream(op)
      object_id = op.use!('object')
      object = entities.get_any(object_id)
      use_arguments(op) do |args|
        pipeline = args.use!('pipeline')
        opts = {}
        if batch_size = args.use('batchSize')
          opts[:batch_size] = batch_size
        end
        if comment = args.use('comment')
          opts[:comment] = comment
        end
        if full_document = args.use('fullDocument')
          opts[:full_document] = full_document
        end
        if full_document_before_change = args.use('fullDocumentBeforeChange')
          opts[:full_document_before_change] = full_document_before_change
        end
        cs = object.watch(pipeline, **opts)
        name = op.use!('saveResultAsEntity')
        entities.set(:change_stream, name, cs)
      end
    end

    def iterate_until_document_or_error(op)
      object_id = op.use!('object')
      object = entities.get(:change_stream, object_id)
      object.to_enum.next
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongo-2.18.0.beta1 spec/runners/unified/change_stream_operations.rb