lib/moped/protocol/query.rb in moped-1.3.1 vs lib/moped/protocol/query.rb in moped-1.3.2
- old
+ new
@@ -76,10 +76,16 @@
attr_reader :database
# @return [String, Symbol] the collection to query
attr_reader :collection
+ attr_accessor :batch_size
+
+ def no_timeout=(enable)
+ @flags |= [:no_cursor_timeout] if enable
+ end
+
# Create a new query command.
#
# @example
# Query.new "moped", "users", { name: "John" },
# skip: 5,
@@ -103,14 +109,15 @@
@collection = collection
@full_collection_name = "#{database}.#{collection}"
@selector = selector
@request_id = options[:request_id]
- @flags = options[:flags]
+ @flags = options[:flags] || []
@limit = options[:limit]
@skip = options[:skip]
@fields = options[:fields]
+ @batch_size = options[:batch_size]
end
def log_inspect
type = "QUERY"
fields = []
@@ -119,9 +126,10 @@
fields << ["collection=%s", collection]
fields << ["selector=%s", selector.inspect]
fields << ["flags=%s", flags.inspect]
fields << ["limit=%s", limit.inspect]
fields << ["skip=%s", skip.inspect]
+ fields << ["batch_size=%s", batch_size.inspect]
fields << ["fields=%s", self.fields.inspect]
f, v = fields.transpose
f.join(" ") % v
end