Example usage for com.mongodb WriteResult WriteResult

List of usage examples for com.mongodb WriteResult WriteResult

Introduction

In this page you can find the example usage for com.mongodb WriteResult WriteResult.

Prototype

public WriteResult(final int n, final boolean updateOfExisting, @Nullable final Object upsertedId) 

Source Link

Document

Construct a new instance.

Usage

From source file:net.vz.mongodb.jackson.JacksonDBCollection.java

License:Apache License

/**
 * Inserts an object into the database.//from   ww  w.java  2  s.c  o  m
 * if the objects _id is null, one will be generated
 * you can get the _id that was generated by calling getSavedObject() or getSavedId() on the result
 *
 * @param object The object to insert
 * @return The result
 * @throws MongoException If an error occurred
 */
public WriteResult<T, K> insert(T object) throws MongoException {
    DBObject dbObject = convertToDbObject(object);
    return new WriteResult<T, K>(this, dbCollection.insert(dbObject), dbObject);
}

From source file:net.vz.mongodb.jackson.JacksonDBCollection.java

License:Apache License

/**
 * Inserts an object into the database.//from ww  w . j  a  v a 2 s .c o m
 * if the objects _id is null, one will be generated
 * you can get the _id that was generated by calling getSavedObject() or getSavedId() on the result
 *
 * @param object  The object to insert
 * @param concern the write concern
 * @return The result
 * @throws MongoException If an error occurred
 */
public WriteResult<T, K> insert(T object, WriteConcern concern) throws MongoException {
    DBObject dbObject = convertToDbObject(object);
    return new WriteResult<T, K>(this, dbCollection.insert(dbObject, concern), dbObject);
}

From source file:net.vz.mongodb.jackson.JacksonDBCollection.java

License:Apache License

/**
 * Inserts objects into the database.//w ww.  j a v a  2s  .  co m
 * if the objects _id is null, one will be generated
 * you can get the _id that were generated by calling getSavedObjects() or getSavedIds() on the result
 *
 * @param objects The objects to insert
 * @return The result
 * @throws MongoException If an error occurred
 */
public WriteResult<T, K> insert(T... objects) throws MongoException {
    DBObject[] dbObjects = convertToDbObjects(objects);
    return new WriteResult<T, K>(this, dbCollection.insert(dbObjects), dbObjects);
}

From source file:net.vz.mongodb.jackson.JacksonDBCollection.java

License:Apache License

/**
 * Inserts objects into the database.// w  w w .  j  a  v a2s. c  o m
 * if the objects _id is null, one will be generated
 * you can get the _id that were generated by calling getSavedObjects() or getSavedIds() on the result
 *
 * @param objects The objects to insert
 * @param concern the write concern
 * @return The result
 * @throws MongoException If an error occurred
 */
public WriteResult<T, K> insert(WriteConcern concern, T... objects) throws MongoException {
    DBObject[] dbObjects = convertToDbObjects(objects);
    return new WriteResult<T, K>(this, dbCollection.insert(concern, dbObjects), dbObjects);
}

From source file:net.vz.mongodb.jackson.JacksonDBCollection.java

License:Apache License

/**
 * Saves an object to this collection (does insert or update based on the object _id).
 *
 * @param object  the <code>DBObject</code> to save
 * @param concern the write concern//w ww . ja va 2 s .  c o m
 * @return The result
 * @throws MongoException If an error occurred
 */
public WriteResult<T, K> save(T object, WriteConcern concern) throws MongoException {
    DBObject dbObject = convertToDbObject(object);
    return new WriteResult<T, K>(this, dbCollection.save(dbObject, concern), dbObject);
}