Class: VertxMongo::MongoClient
- Inherits:
-
Object
- Object
- VertxMongo::MongoClient
- Defined in:
- /Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb
Overview
A Vert.x service used to interact with MongoDB server instances.
Class Method Summary (collapse)
-
+ (::VertxMongo::MongoClient) create_non_shared(vertx = nil, config = nil)
Create a Mongo client which maintains its own data source.
-
+ (::VertxMongo::MongoClient) create_shared(vertx = nil, config = nil, dataSourceName = nil)
Create a Mongo client which shares its data source with any other Mongo clients created with the same data source name.
Instance Method Summary (collapse)
-
- (void) close
Close the client and release its resources.
-
- (self) count(collection = nil, query = nil) { ... }
Count matching documents in a collection.
-
- (self) create_collection(collectionName = nil) { ... }
Create a new collection.
-
- (self) drop_collection(collection = nil) { ... }
Drop a collection.
-
- (self) find(collection = nil, query = nil) { ... }
Find matching documents in the specified collection.
-
- (self) find_one(collection = nil, query = nil, fields = nil) { ... }
Find a single matching document in the specified collection.
-
- (self) find_with_options(collection = nil, query = nil, options = nil) { ... }
Find matching documents in the specified collection, specifying options.
-
- (self) get_collections { ... }
Get a list of all collections in the database.
-
- (self) insert(collection = nil, document = nil) { ... }
Insert a document in the specified collection.
-
- (self) insert_with_options(collection = nil, document = nil, writeOption = nil) { ... }
Insert a document in the specified collection with the specified write option.
-
- (self) remove(collection = nil, query = nil) { ... }
Remove matching documents from a collection.
-
- (self) remove_one(collection = nil, query = nil) { ... }
Remove a single matching document from a collection.
-
- (self) remove_one_with_options(collection = nil, query = nil, writeOption = nil) { ... }
Remove a single matching document from a collection with the specified write option.
-
- (self) remove_with_options(collection = nil, query = nil, writeOption = nil) { ... }
Remove matching documents from a collection with the specified write option.
-
- (self) replace(collection = nil, query = nil, replace = nil) { ... }
Replace matching documents in the specified collection.
-
- (self) replace_with_options(collection = nil, query = nil, replace = nil, options = nil) { ... }
Replace matching documents in the specified collection, specifying options.
-
- (self) run_command(commandName = nil, command = nil) { ... }
Run an arbitrary MongoDB command.
-
- (self) save(collection = nil, document = nil) { ... }
Save a document in the specified collection.
-
- (self) save_with_options(collection = nil, document = nil, writeOption = nil) { ... }
Save a document in the specified collection with the specified write option.
-
- (self) update(collection = nil, query = nil, update = nil) { ... }
Update matching documents in the specified collection.
-
- (self) update_with_options(collection = nil, query = nil, update = nil, options = nil) { ... }
Update matching documents in the specified collection, specifying options.
Class Method Details
+ (::VertxMongo::MongoClient) create_non_shared(vertx = nil, config = nil)
Create a Mongo client which maintains its own data source.
20 21 22 23 24 25 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 20 def self.create_non_shared(vertx=nil,config=nil) if vertx.class.method_defined?(:j_del) && config.class == Hash && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtMongo::MongoClient.java_method(:createNonShared, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(vertx.j_del,::Vertx::Util::Utils.to_json_object(config)),::VertxMongo::MongoClient) end raise ArgumentError, "Invalid arguments when calling create_non_shared(vertx,config)" end |
+ (::VertxMongo::MongoClient) create_shared(vertx = nil, config = nil, dataSourceName = nil)
Create a Mongo client which shares its data source with any other Mongo clients created with the same
data source name
32 33 34 35 36 37 38 39 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 32 def self.create_shared(vertx=nil,config=nil,dataSourceName=nil) if vertx.class.method_defined?(:j_del) && config.class == Hash && !block_given? && dataSourceName == nil return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtMongo::MongoClient.java_method(:createShared, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class]).call(vertx.j_del,::Vertx::Util::Utils.to_json_object(config)),::VertxMongo::MongoClient) elsif vertx.class.method_defined?(:j_del) && config.class == Hash && dataSourceName.class == String && !block_given? return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtMongo::MongoClient.java_method(:createShared, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::java.lang.String.java_class]).call(vertx.j_del,::Vertx::Util::Utils.to_json_object(config),dataSourceName),::VertxMongo::MongoClient) end raise ArgumentError, "Invalid arguments when calling create_shared(vertx,config,dataSourceName)" end |
Instance Method Details
- (void) close
This method returns an undefined value.
Close the client and release its resources
290 291 292 293 294 295 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 290 def close if !block_given? return @j_del.java_method(:close, []).call() end raise ArgumentError, "Invalid arguments when calling close()" end |
- (self) count(collection = nil, query = nil) { ... }
Count matching documents in a collection.
187 188 189 190 191 192 193 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 187 def count(collection=nil,query=nil) if collection.class == String && query.class == Hash && block_given? @j_del.java_method(:count, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(query),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) })) return self end raise ArgumentError, "Invalid arguments when calling count(collection,query)" end |
- (self) create_collection(collectionName = nil) { ... }
Create a new collection
248 249 250 251 252 253 254 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 248 def create_collection(collectionName=nil) if collectionName.class == String && block_given? @j_del.java_method(:createCollection, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(collectionName,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) return self end raise ArgumentError, "Invalid arguments when calling create_collection(collectionName)" end |
- (self) drop_collection(collection = nil) { ... }
Drop a collection
269 270 271 272 273 274 275 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 269 def drop_collection(collection=nil) if collection.class == String && block_given? @j_del.java_method(:dropCollection, [Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) return self end raise ArgumentError, "Invalid arguments when calling drop_collection(collection)" end |
- (self) find(collection = nil, query = nil) { ... }
Find matching documents in the specified collection
149 150 151 152 153 154 155 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 149 def find(collection=nil,query=nil) if collection.class == String && query.class == Hash && block_given? @j_del.java_method(:find, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(query),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result.to_a.map { |elt| elt != nil ? JSON.parse(elt.encode) : nil } : nil) })) return self end raise ArgumentError, "Invalid arguments when calling find(collection,query)" end |
- (self) find_one(collection = nil, query = nil, fields = nil) { ... }
Find a single matching document in the specified collection
175 176 177 178 179 180 181 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 175 def find_one(collection=nil,query=nil,fields=nil) if collection.class == String && query.class == Hash && fields.class == Hash && block_given? @j_del.java_method(:findOne, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(query),::Vertx::Util::Utils.to_json_object(fields),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) })) return self end raise ArgumentError, "Invalid arguments when calling find_one(collection,query,fields)" end |
- (self) find_with_options(collection = nil, query = nil, options = nil) { ... }
Find matching documents in the specified collection, specifying options
162 163 164 165 166 167 168 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 162 def (collection=nil,query=nil,=nil) if collection.class == String && query.class == Hash && .class == Hash && block_given? @j_del.java_method(:findWithOptions, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxExtMongo::FindOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(query),Java::IoVertxExtMongo::FindOptions.new(::Vertx::Util::Utils.to_json_object()),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result.to_a.map { |elt| elt != nil ? JSON.parse(elt.encode) : nil } : nil) })) return self end raise ArgumentError, "Invalid arguments when calling find_with_options(collection,query,options)" end |
- (self) get_collections { ... }
Get a list of all collections in the database.
258 259 260 261 262 263 264 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 258 def get_collections if block_given? @j_del.java_method(:getCollections, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result.to_a.map { |elt| elt } : nil) })) return self end raise ArgumentError, "Invalid arguments when calling get_collections()" end |
- (self) insert(collection = nil, document = nil) { ... }
Insert a document in the specified collection
70 71 72 73 74 75 76 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 70 def insert(collection=nil,document=nil) if collection.class == String && document.class == Hash && block_given? @j_del.java_method(:insert, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(document),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) })) return self end raise ArgumentError, "Invalid arguments when calling insert(collection,document)" end |
- (self) insert_with_options(collection = nil, document = nil, writeOption = nil) { ... }
Insert a document in the specified collection with the specified write option
83 84 85 86 87 88 89 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 83 def (collection=nil,document=nil,writeOption=nil) if collection.class == String && document.class == Hash && writeOption.class == Symbol && block_given? @j_del.java_method(:insertWithOptions, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxExtMongo::WriteOption.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(document),Java::IoVertxExtMongo::WriteOption.valueOf(writeOption),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) })) return self end raise ArgumentError, "Invalid arguments when calling insert_with_options(collection,document,writeOption)" end |
- (self) remove(collection = nil, query = nil) { ... }
Remove matching documents from a collection
199 200 201 202 203 204 205 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 199 def remove(collection=nil,query=nil) if collection.class == String && query.class == Hash && block_given? @j_del.java_method(:remove, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(query),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) return self end raise ArgumentError, "Invalid arguments when calling remove(collection,query)" end |
- (self) remove_one(collection = nil, query = nil) { ... }
Remove a single matching document from a collection
224 225 226 227 228 229 230 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 224 def remove_one(collection=nil,query=nil) if collection.class == String && query.class == Hash && block_given? @j_del.java_method(:removeOne, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(query),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) return self end raise ArgumentError, "Invalid arguments when calling remove_one(collection,query)" end |
- (self) remove_one_with_options(collection = nil, query = nil, writeOption = nil) { ... }
Remove a single matching document from a collection with the specified write option
237 238 239 240 241 242 243 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 237 def (collection=nil,query=nil,writeOption=nil) if collection.class == String && query.class == Hash && writeOption.class == Symbol && block_given? @j_del.java_method(:removeOneWithOptions, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxExtMongo::WriteOption.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(query),Java::IoVertxExtMongo::WriteOption.valueOf(writeOption),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) return self end raise ArgumentError, "Invalid arguments when calling remove_one_with_options(collection,query,writeOption)" end |
- (self) remove_with_options(collection = nil, query = nil, writeOption = nil) { ... }
Remove matching documents from a collection with the specified write option
212 213 214 215 216 217 218 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 212 def (collection=nil,query=nil,writeOption=nil) if collection.class == String && query.class == Hash && writeOption.class == Symbol && block_given? @j_del.java_method(:removeWithOptions, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxExtMongo::WriteOption.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(query),Java::IoVertxExtMongo::WriteOption.valueOf(writeOption),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) return self end raise ArgumentError, "Invalid arguments when calling remove_with_options(collection,query,writeOption)" end |
- (self) replace(collection = nil, query = nil, replace = nil) { ... }
Replace matching documents in the specified collection
123 124 125 126 127 128 129 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 123 def replace(collection=nil,query=nil,replace=nil) if collection.class == String && query.class == Hash && replace.class == Hash && block_given? @j_del.java_method(:replace, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(query),::Vertx::Util::Utils.to_json_object(replace),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) return self end raise ArgumentError, "Invalid arguments when calling replace(collection,query,replace)" end |
- (self) replace_with_options(collection = nil, query = nil, replace = nil, options = nil) { ... }
Replace matching documents in the specified collection, specifying options
137 138 139 140 141 142 143 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 137 def (collection=nil,query=nil,replace=nil,=nil) if collection.class == String && query.class == Hash && replace.class == Hash && .class == Hash && block_given? @j_del.java_method(:replaceWithOptions, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxExtMongo::UpdateOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(query),::Vertx::Util::Utils.to_json_object(replace),Java::IoVertxExtMongo::UpdateOptions.new(::Vertx::Util::Utils.to_json_object()),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) return self end raise ArgumentError, "Invalid arguments when calling replace_with_options(collection,query,replace,options)" end |
- (self) run_command(commandName = nil, command = nil) { ... }
Run an arbitrary MongoDB command.
281 282 283 284 285 286 287 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 281 def run_command(commandName=nil,command=nil) if commandName.class == String && command.class == Hash && block_given? @j_del.java_method(:runCommand, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(commandName,::Vertx::Util::Utils.to_json_object(command),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result != nil ? JSON.parse(ar.result.encode) : nil : nil) })) return self end raise ArgumentError, "Invalid arguments when calling run_command(commandName,command)" end |
- (self) save(collection = nil, document = nil) { ... }
Save a document in the specified collection
45 46 47 48 49 50 51 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 45 def save(collection=nil,document=nil) if collection.class == String && document.class == Hash && block_given? @j_del.java_method(:save, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(document),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) })) return self end raise ArgumentError, "Invalid arguments when calling save(collection,document)" end |
- (self) save_with_options(collection = nil, document = nil, writeOption = nil) { ... }
Save a document in the specified collection with the specified write option
58 59 60 61 62 63 64 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 58 def (collection=nil,document=nil,writeOption=nil) if collection.class == String && document.class == Hash && writeOption.class == Symbol && block_given? @j_del.java_method(:saveWithOptions, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxExtMongo::WriteOption.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(document),Java::IoVertxExtMongo::WriteOption.valueOf(writeOption),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ar.result : nil) })) return self end raise ArgumentError, "Invalid arguments when calling save_with_options(collection,document,writeOption)" end |
- (self) update(collection = nil, query = nil, update = nil) { ... }
Update matching documents in the specified collection
96 97 98 99 100 101 102 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 96 def update(collection=nil,query=nil,update=nil) if collection.class == String && query.class == Hash && update.class == Hash && block_given? @j_del.java_method(:update, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(query),::Vertx::Util::Utils.to_json_object(update),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) return self end raise ArgumentError, "Invalid arguments when calling update(collection,query,update)" end |
- (self) update_with_options(collection = nil, query = nil, update = nil, options = nil) { ... }
Update matching documents in the specified collection, specifying options
110 111 112 113 114 115 116 |
# File '/Users/julien/java/vertx-aggregator/modules/vertx-mongo-client/vertx-mongo-client/src/main/resources/vertx-mongo/mongo_client.rb', line 110 def (collection=nil,query=nil,update=nil,=nil) if collection.class == String && query.class == Hash && update.class == Hash && .class == Hash && block_given? @j_del.java_method(:updateWithOptions, [Java::java.lang.String.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxCoreJson::JsonObject.java_class,Java::IoVertxExtMongo::UpdateOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(collection,::Vertx::Util::Utils.to_json_object(query),::Vertx::Util::Utils.to_json_object(update),Java::IoVertxExtMongo::UpdateOptions.new(::Vertx::Util::Utils.to_json_object()),(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) })) return self end raise ArgumentError, "Invalid arguments when calling update_with_options(collection,query,update,options)" end |