Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
/** @module vertx-mongo-js/mongo_client */
var utils = require('vertx-js/util/utils');
var Vertx = require('vertx-js/vertx');
var io = Packages.io;
var JsonObject = io.vertx.core.json.JsonObject;
var JMongoClient = Java.type('io.vertx.ext.mongo.MongoClient');
var MongoClientDeleteResult = Java.type('io.vertx.ext.mongo.MongoClientDeleteResult');
var IndexOptions = Java.type('io.vertx.ext.mongo.IndexOptions');
var BulkOperation = Java.type('io.vertx.ext.mongo.BulkOperation');
var BulkWriteOptions = Java.type('io.vertx.ext.mongo.BulkWriteOptions');
var FindOptions = Java.type('io.vertx.ext.mongo.FindOptions');
var MongoClientBulkWriteResult = Java.type('io.vertx.ext.mongo.MongoClientBulkWriteResult');
var MongoClientUpdateResult = Java.type('io.vertx.ext.mongo.MongoClientUpdateResult');
var UpdateOptions = Java.type('io.vertx.ext.mongo.UpdateOptions');
/**
A Vert.x service used to interact with MongoDB server instances.
@class
*/
var MongoClient = function(j_val) {
var j_mongoClient = j_val;
var that = this;
/**
Save a document in the specified collection
This operation might change _id field of document parameter
@public
@param collection {string} the collection
@param document {Object} the document
@param resultHandler {function} result handler will be provided with the id if document didn't already have one
@return {MongoClient}
*/
this.save = function(collection, document, resultHandler) {
var __args = arguments;
if (__args.length === 3 && typeof __args[0] === 'string' && (typeof __args[1] === 'object' && __args[1] != null) && typeof __args[2] === 'function') {
j_mongoClient["save(java.lang.String,io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](collection, utils.convParamJsonObject(document), function(ar) {
if (ar.succeeded()) {
resultHandler(ar.result(), null);
} else {
resultHandler(null, ar.cause());
}
});
return that;
} else throw new TypeError('function invoked with invalid arguments');
};
/**
Save a document in the specified collection with the specified write option
This operation might change _id field of document parameter
@public
@param collection {string} the collection
@param document {Object} the document
@param writeOption {Object} the write option to use
@param resultHandler {function} result handler will be provided with the id if document didn't already have one
@return {MongoClient}
*/
this.saveWithOptions = function(collection, document, writeOption, resultHandler) {
var __args = arguments;
if (__args.length === 4 && typeof __args[0] === 'string' && (typeof __args[1] === 'object' && __args[1] != null) && typeof __args[2] === 'string' && typeof __args[3] === 'function') {
j_mongoClient["saveWithOptions(java.lang.String,io.vertx.core.json.JsonObject,io.vertx.ext.mongo.WriteOption,io.vertx.core.Handler)"](collection, utils.convParamJsonObject(document), io.vertx.ext.mongo.WriteOption.valueOf(writeOption), function(ar) {
if (ar.succeeded()) {
resultHandler(ar.result(), null);
} else {
resultHandler(null, ar.cause());
}
});
return that;
} else throw new TypeError('function invoked with invalid arguments');
};
/**
Insert a document in the specified collection
This operation might change _id field of document parameter
@public
@param collection {string} the collection
@param document {Object} the document
@param resultHandler {function} result handler will be provided with the id if document didn't already have one
@return {MongoClient}
*/
this.insert = function(collection, document, resultHandler) {
var __args = arguments;
if (__args.length === 3 && typeof __args[0] === 'string' && (typeof __args[1] === 'object' && __args[1] != null) && typeof __args[2] === 'function') {
j_mongoClient["insert(java.lang.String,io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](collection, utils.convParamJsonObject(document), function(ar) {
if (ar.succeeded()) {
resultHandler(ar.result(), null);
} else {
resultHandler(null, ar.cause());
}
});
return that;
} else throw new TypeError('function invoked with invalid arguments');
};
/**
Insert a document in the specified collection with the specified write option
This operation might change _id field of document parameter
@public
@param collection {string} the collection
@param document {Object} the document
@param writeOption {Object} the write option to use
@param resultHandler {function} result handler will be provided with the id if document didn't already have one
@return {MongoClient}
*/
this.insertWithOptions = function(collection, document, writeOption, resultHandler) {
var __args = arguments;
if (__args.length === 4 && typeof __args[0] === 'string' && (typeof __args[1] === 'object' && __args[1] != null) && typeof __args[2] === 'string' && typeof __args[3] === 'function') {
j_mongoClient["insertWithOptions(java.lang.String,io.vertx.core.json.JsonObject,io.vertx.ext.mongo.WriteOption,io.vertx.core.Handler)"](collection, utils.convParamJsonObject(document), io.vertx.ext.mongo.WriteOption.valueOf(writeOption), function(ar) {
if (ar.succeeded()) {
resultHandler(ar.result(), null);
} else {
resultHandler(null, ar.cause());
}
});
return that;
} else throw new TypeError('function invoked with invalid arguments');
};
/**
Update matching documents in the specified collection
@public
@param collection {string} the collection
@param query {Object} query used to match the documents
@param update {Object} used to describe how the documents will be updated
@param resultHandler {function} will be called when complete
@return {MongoClient}
*/
this.update = function(collection, query, update, resultHandler) {
var __args = arguments;
if (__args.length === 4 && typeof __args[0] === 'string' && (typeof __args[1] === 'object' && __args[1] != null) && (typeof __args[2] === 'object' && __args[2] != null) && typeof __args[3] === 'function') {
j_mongoClient["update(java.lang.String,io.vertx.core.json.JsonObject,io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](collection, utils.convParamJsonObject(query), utils.convParamJsonObject(update), function(ar) {
if (ar.succeeded()) {
resultHandler(null, null);
} else {
resultHandler(null, ar.cause());
}
});
return that;
} else throw new TypeError('function invoked with invalid arguments');
};
/**
Update matching documents in the specified collection and return the handler with MongoClientUpdateResult result
@public
@param collection {string} the collection
@param query {Object} query used to match the documents
@param update {Object} used to describe how the documents will be updated
@param resultHandler {function} will be called when complete
@return {MongoClient}
*/
this.updateCollection = function(collection, query, update, resultHandler) {
var __args = arguments;
if (__args.length === 4 && typeof __args[0] === 'string' && (typeof __args[1] === 'object' && __args[1] != null) && (typeof __args[2] === 'object' && __args[2] != null) && typeof __args[3] === 'function') {
j_mongoClient["updateCollection(java.lang.String,io.vertx.core.json.JsonObject,io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](collection, utils.convParamJsonObject(query), utils.convParamJsonObject(update), function(ar) {
if (ar.succeeded()) {
resultHandler(utils.convReturnDataObject(ar.result()), null);
} else {
resultHandler(null, ar.cause());
}
});
return that;
} else throw new TypeError('function invoked with invalid arguments');
};
/**
Update matching documents in the specified collection, specifying options
@public
@param collection {string} the collection
@param query {Object} query used to match the documents
@param update {Object} used to describe how the documents will be updated
@param options {Object} options to configure the update
@param resultHandler {function} will be called when complete
@return {MongoClient}
*/
this.updateWithOptions = function(collection, query, update, options, resultHandler) {
var __args = arguments;
if (__args.length === 5 && typeof __args[0] === 'string' && (typeof __args[1] === 'object' && __args[1] != null) && (typeof __args[2] === 'object' && __args[2] != null) && (typeof __args[3] === 'object' && __args[3] != null) && typeof __args[4] === 'function') {
j_mongoClient["updateWithOptions(java.lang.String,io.vertx.core.json.JsonObject,io.vertx.core.json.JsonObject,io.vertx.ext.mongo.UpdateOptions,io.vertx.core.Handler)"](collection, utils.convParamJsonObject(query), utils.convParamJsonObject(update), options != null ? new UpdateOptions(new JsonObject(Java.asJSONCompatible(options))) : null, function(ar) {
if (ar.succeeded()) {
resultHandler(null, null);
} else {
resultHandler(null, ar.cause());
}
});
return that;
} else throw new TypeError('function invoked with invalid arguments');
};
/**
Update matching documents in the specified collection, specifying options and return the handler with MongoClientUpdateResult result
@public
@param collection {string} the collection
@param query {Object} query used to match the documents
@param update {Object} used to describe how the documents will be updated
@param options {Object} options to configure the update
@param resultHandler {function} will be called when complete
@return {MongoClient}
*/
this.updateCollectionWithOptions = function(collection, query, update, options, resultHandler) {
var __args = arguments;
if (__args.length === 5 && typeof __args[0] === 'string' && (typeof __args[1] === 'object' && __args[1] != null) && (typeof __args[2] === 'object' && __args[2] != null) && (typeof __args[3] === 'object' && __args[3] != null) && typeof __args[4] === 'function') {
j_mongoClient["updateCollectionWithOptions(java.lang.String,io.vertx.core.json.JsonObject,io.vertx.core.json.JsonObject,io.vertx.ext.mongo.UpdateOptions,io.vertx.core.Handler)"](collection, utils.convParamJsonObject(query), utils.convParamJsonObject(update), options != null ? new UpdateOptions(new JsonObject(Java.asJSONCompatible(options))) : null, function(ar) {
if (ar.succeeded()) {
resultHandler(utils.convReturnDataObject(ar.result()), null);
} else {
resultHandler(null, ar.cause());
}
});
return that;
} else throw new TypeError('function invoked with invalid arguments');
};
/**
Replace matching documents in the specified collection
This operation might change _id field of replace parameter
@public
@param collection {string} the collection
@param query {Object} query used to match the documents
@param replace {Object} all matching documents will be replaced with this
@param resultHandler {function} will be called when complete
@return {MongoClient}
*/
this.replace = function(collection, query, replace, resultHandler) {
var __args = arguments;
if (__args.length === 4 && typeof __args[0] === 'string' && (typeof __args[1] === 'object' && __args[1] != null) && (typeof __args[2] === 'object' && __args[2] != null) && typeof __args[3] === 'function') {
j_mongoClient["replace(java.lang.String,io.vertx.core.json.JsonObject,io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](collection, utils.convParamJsonObject(query), utils.convParamJsonObject(replace), function(ar) {
if (ar.succeeded()) {
resultHandler(null, null);
} else {
resultHandler(null, ar.cause());
}
});
return that;
} else throw new TypeError('function invoked with invalid arguments');
};
/**
Replace matching documents in the specified collection and return the handler with MongoClientUpdateResult result
@public
@param collection {string} the collection
@param query {Object} query used to match the documents
@param replace {Object} all matching documents will be replaced with this
@param resultHandler {function} will be called when complete
@return {MongoClient}
*/
this.replaceDocuments = function(collection, query, replace, resultHandler) {
var __args = arguments;
if (__args.length === 4 && typeof __args[0] === 'string' && (typeof __args[1] === 'object' && __args[1] != null) && (typeof __args[2] === 'object' && __args[2] != null) && typeof __args[3] === 'function') {
j_mongoClient["replaceDocuments(java.lang.String,io.vertx.core.json.JsonObject,io.vertx.core.json.JsonObject,io.vertx.core.Handler)"](collection, utils.convParamJsonObject(query), utils.convParamJsonObject(replace), function(ar) {
if (ar.succeeded()) {
resultHandler(utils.convReturnDataObject(ar.result()), null);
} else {
resultHandler(null, ar.cause());
}
});
return that;
} else throw new TypeError('function invoked with invalid arguments');
};
/**
Replace matching documents in the specified collection, specifying options
This operation might change _id field of replace parameter
@public
@param collection {string} the collection
@param query {Object} query used to match the documents
@param replace {Object} all matching documents will be replaced with this
@param options {Object} options to configure the replace
@param resultHandler {function} will be called when complete
@return {MongoClient}
*/
this.replaceWithOptions = function(collection, query, replace, options, resultHandler) {
var __args = arguments;
if (__args.length === 5 && typeof __args[0] === 'string' && (typeof __args[1] === 'object' && __args[1] != null) && (typeof __args[2] === 'object' && __args[2] != null) && (typeof __args[3] === 'object' && __args[3] != null) && typeof __args[4] === 'function') {
j_mongoClient["replaceWithOptions(java.lang.String,io.vertx.core.json.JsonObject,io.vertx.core.json.JsonObject,io.vertx.ext.mongo.UpdateOptions,io.vertx.core.Handler)"](collection, utils.convParamJsonObject(query), utils.convParamJsonObject(replace), options != null ? new UpdateOptions(new JsonObject(Java.asJSONCompatible(options))) : null, function(ar) {
if (ar.succeeded()) {
resultHandler(null, null);
} else {
resultHandler(null, ar.cause());
}
});
return that;
} else throw new TypeError('function invoked with invalid arguments');
};
/**
Replace matching documents in the specified collection, specifying options and return the handler with MongoClientUpdateResult result
@public
@param collection {string} the collection
@param query {Object} query used to match the documents
@param replace {Object} all matching documents will be replaced with this
@param options {Object} options to configure the replace
@param resultHandler {function} will be called when complete
@return {MongoClient}
*/
this.replaceDocumentsWithOptions = function(collection, query, replace, options, resultHandler) {
var __args = arguments;
if (__args.length === 5 && typeof __args[0] === 'string' && (typeof __args[1] === 'object' && __args[1] != null) && (typeof __args[2] === 'object' && __args[2] != null) && (typeof __args[3] === 'object' && __args[3] != null) && typeof __args[4] === 'function') {
j_mongoClient["replaceDocumentsWithOptions(java.lang.String,io.vertx.core.json.JsonObject,io.vertx.core.json.JsonObject,io.vertx.ext.mongo.UpdateOptions,io.vertx.core.Handler)"](collection, utils.convParamJsonObject(query), utils.convParamJsonObject(replace), options != null ? new UpdateOptions(new JsonObject(Java.asJSONCompatible(options))) : null, function(ar) {
if (ar.succeeded()) {
resultHandler(utils.convReturnDataObject(ar.result()), null);
} else {
resultHandler(null, ar.cause());
}
});
return that;
} else throw new TypeError('function invoked with invalid arguments');
};
/**
Execute a bulk operation. Can insert, update, replace, and/or delete multiple documents with one request.
@public
@param collection {string} the collection
@param operations {Array.