类:Mongo::Database::View
Overview
表示数据库视图的类。
实例属性摘要折叠
-
# batch_size ⇒ 整数
只读
batch_size 发送 listCollections 命令时批量结果的大小。
-
# 集合 ="Collection"(集合)
只读
集合 命令集合。
- #数据库⇒ 对象 只读 private
-
# limit ⇒ 整数
只读
限制 发送命令时的限制。
-
# operation_timeout_ms ⇒ Integer | nil |作为选项传递给视图的 timeout_ms 值。
只读
private
整数 | nil |作为选项传递给视图的 timeout_ms 值。
CursorHost 包含的属性
实例方法摘要折叠
-
#aggregate (pipeline, options = {}) ⇒ Collection::View::Aggregation
private
在数据库视图上执行聚合。
-
# collection_names (options = {}) ⇒ Array<String>
获取数据库中所有非系统集合的名称。
-
#initialize(database, options = {}) ⇒ View
构造函数
创建新的数据库视图。
-
# list_collections (options = {}) ⇒ Array<Hash>
获取有关数据库中所有集合的信息。
-
# operation_timeups (opts = {}) ⇒ 哈希
private
在操作级别(如果有)上设立的Timeout_ms 值。
-
#timeout_ms ⇒ Integer | nil
用于此操作的 timeout_ms 值;指定为视图的选项,或从数据库继承。
Cursor::NonTailable 中包含的方法
CursorHost 包含的方法
Retryable 中包含的方法
#read_worker 、 #select_server 、 #write_worker
构造函数详情
#initialize(database, options = {}) ⇒ View
创建新的数据库视图。
149 150 151 152 153 154 155 156 157 158 |
# File 'lib/ Mongo/ 数据库/view.rb', line 149 def 初始化(database, = {}) @database = database @operation_timeout_ms = .删除(:timeout_ms) validate_timeout_mode!() @batch_size = nil @limit = nil @collection = @database[Database::命令] end |
实例属性详细信息
# batch_size ⇒整数(只读)
返回 batch_size 发送 listCollections 命令时结果批次的大小。
40 41 42 |
# File 'lib/ Mongo/ 数据库/view.rb', line 40 def batch_size @batch_size end |
# collection =" Collection " (只读)
返回集合 命令集合。
46 47 48 |
# File 'lib/ Mongo/ 数据库/view.rb', line 46 def 集合 @collection end |
#数据库⇒对象(只读)
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
161 162 163 |
# File 'lib/ Mongo/ 数据库/view.rb', line 161 def database @database end |
# limit ⇒整数(只读)
返回限制 发送命令时的限制。
43 44 45 |
# File 'lib/ Mongo/ 数据库/view.rb', line 43 def limit @limit end |
# operation_timeout_ms ⇒ Integer | nil |作为选项传递给视图的 timeout_ms 值。(只读)
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
返回整数 | nil |作为选项传递给视图的 timeout_ms 值。
167 168 169 |
# File 'lib/ Mongo/ 数据库/view.rb', line 167 def operation_timeout_ms @operation_timeout_ms end |
实例方法详细信息
#aggregate (pipeline, options = {}) ⇒ Collection::View::Aggregation
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
在数据库视图上执行聚合。
183 184 185 |
# File 'lib/ Mongo/ 数据库/view.rb', line 183 def 聚合(管道, = {}) Collection::查看::聚合(Aggregation).new(self, 管道, ) end |
# collection_names (options = {}) ⇒ Array<String>
返回的集合名称集取决于完成请求的 MongoDB 服务器的版本。
获取数据库中所有非系统集合的名称。
See http://mongodb.com/zh-cn/docs/manual/reference/command/listCollections/
for more information and usage.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/ Mongo/ 数据库/view.rb', line 75 def collection_names( = {}) @batch_size = [:batch_size] 会话 = 客户端.get_session() 上下文 = 操作::上下文.new( 客户端: 客户端, 会话: 会话, operation_timeups: operation_timeups() ) cursor = read_with_retry_cursor(会话, ServerSelector.主节点, self, 上下文: 上下文) do |server| send_initial_query(server, 会话, 上下文, .合并(merge)(name_only: true)) end cursor.map do |信息| if cursor.Initial_result.connection_description.功能.list_collections_enabled? 信息[' name '] else (信息[' name '] && 信息[' name '].子(" #{ @database . name } . ", ' ')) end end.拒绝 do |名称| 名称.start_with?('系统。 ') || 名称.包括?('$') end end |
# list_collections (options = {}) ⇒ Array<Hash>
返回的集合集以及每个集合的信息哈希模式取决于完成请求的 MongoDB 服务器版本。
获取有关数据库中所有集合的信息。
127 128 129 130 |
# File 'lib/ Mongo/ 数据库/view.rb', line 127 def list_collections( = {}) 会话 = 客户端.get_session() collections_info(会话, ServerSelector.主节点, ) end |
# operation_timeups (opts = {}) ⇒ 哈希
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
返回在操作级别(如果有)上设立的timeout_ms 值。
198 199 200 201 202 203 204 205 206 |
# File 'lib/ Mongo/ 数据库/view.rb', line 198 def operation_timeups(opts = {}) {}.点击 do |结果| if opts[:timeout_ms] || operation_timeout_ms 结果[:operation_timeout_ms] = opts.删除(:timeout_ms) || operation_timeout_ms else 结果[:inherited_timeout_ms] = database.timeout_ms end end end |
#timeout_ms ⇒ Integer | nil
用于此操作的 timeout_ms 值;指定为视图的选项,或从数据库继承。
191 192 193 |
# File 'lib/ Mongo/ 数据库/view.rb', line 191 def timeout_ms operation_timeout_ms || database.timeout_ms end |