Examples of WriteResult


Examples of com.mongodb.WriteResult

        if (batch) {
            DBObject[] arr = new BasicDBObject[n];
            for (int i = 0; i < n; i++) {
                arr[i] = new BasicDBObject("_path", "/a" + i);
            }
            WriteResult result = collection.insert(arr);
            if (result.getError() != null) {
                log("Error: " + result.getError());
            }
        } else {
            for (int i = 0; i < n; i++) {
                WriteResult result = collection.insert(new BasicDBObject("_path", "/a" + i));
                if (result.getError() != null) {
                    log("Error: " + result.getError());
                }
            }

        }
View Full Code Here

Examples of com.mongodb.WriteResult

        final MongoDbDataContext dataContext = _updateCallback.getDataContext();
        final BasicDBObject query = dataContext.createMongoDbQuery(getTable(), getWhereItems());
       
        WriteConcern writeConcern = _updateCallback.getWriteConcernAdvisor().adviceDeleteQuery(collection, query);
       
        final WriteResult writeResult = collection.remove(query, writeConcern);
        logger.info("Remove returned result: {}", writeResult);
    }
View Full Code Here

Examples of com.mongodb.WriteResult

        final MongoDbUpdateCallback updateCallback = getUpdateCallback();
        final DBCollection collection = updateCallback.getCollection(getTable().getName());

        final WriteConcern writeConcern = updateCallback.getWriteConcernAdvisor().adviceInsert(collection, doc);

        final WriteResult writeResult = collection.insert(doc, writeConcern);
        logger.info("Insert returned result: {}", writeResult);
    }
View Full Code Here

Examples of com.mongodb.WriteResult

    public final boolean addUser(final DB db,
            final String username, final String password,
            final boolean readOnly) throws StandardCodedException {
        try {
            if (null != db) {
                final WriteResult result = db.addUser(username,
                        password.toCharArray(), readOnly);
                if (StringUtils.hasText(result.getError())) {
                    throw this.getError500(result.getError());
                }
                return true;
            }
            throw this.getError503("Database cannot be a NULL Object!");
        } catch (Throwable t) {
View Full Code Here

Examples of com.mongodb.WriteResult

    public final boolean removeUser(final DB db,
            final String username) throws StandardCodedException {
        try {
            if (null != db) {
                final WriteResult result = db.removeUser(username);
                if (StringUtils.hasText(result.getError())) {
                    throw this.getError500(result.getError());
                }
                return true;
            }
            throw this.getError503("Database cannot be a NULL Object!");
        } catch (Throwable t) {
View Full Code Here

Examples of com.mongodb.WriteResult

        }
    }

    public int remove(final DBObject filter) throws StandardCodedException {
        try {
            final WriteResult result;
            result = _coll.remove(filter);

            if (StringUtils.hasText(result.getError())) {
                throw this.getError418(result.getError());
            }
            return result.getN();
        } catch (Throwable t) {
            throw this.getError500(t);
        }
    }
View Full Code Here

Examples of com.mongodb.WriteResult

    }

    private boolean update(final DBObject query, final DBObject object,
            final boolean upsert, final boolean multi)
            throws StandardCodedException {
        final WriteResult result = _coll.update(query, object, upsert, multi);
        if (StringUtils.hasText(result.getError())) {
            throw this.getError418(result.getError());
        }
        return this.isUpdatedExisting(result);
    }
View Full Code Here

Examples of com.mongodb.WriteResult

    }

    private DBObject merge(final DBObject object, final Object id,
            final String[] excludeProperties)
            throws StandardCodedException {
        WriteResult result;
        final DBObject existing = this.findById(id);
        BeeMongoUtils.merge(object, existing, excludeProperties);
        // removeOne empty arrays before save
        final DBObject item = this.removeEmptyArrays(existing);
        // save
        result = _coll.save(item);

        if (StringUtils.hasText(result.getError())) {
            throw this.getError418(result.getError());
        }

        return item;
    }
View Full Code Here

Examples of com.mongodb.WriteResult

            builder.add("base", state.get("base"));
        }
        builder.add("head", head.toString());
        DBObject nextState = builder.get();

        WriteResult result =
                journals.update(state, nextState, false, false, concern);
        if (result.getN() == 1) {
            state = nextState;
            stateLastUpdated = System.nanoTime();
            return true;
        } else {
            // force refresh when next accessed
View Full Code Here

Examples of com.mongodb.WriteResult

        long start = start();
        try {
            if (collection == Collection.NODES) {
                nodesCache.invalidate(key);
            }
            WriteResult writeResult = dbCollection.remove(getByKeyQuery(key).get(), WriteConcern.SAFE);
            if (writeResult.getError() != null) {
                throw new MicroKernelException("Remove failed: " + writeResult.getError());
            }
        } finally {
            end(start);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.