Package com.mongodb

Examples of com.mongodb.DBCollection.save()


    // Given
    DBCollection col = db.createCollection("testCollection", new BasicDBObject());

    // When
    col.save(new BasicDBObject("testDoc", new Date()));

    // Then
    assertThat(col.getCount()).isEqualTo(1L);
  }
View Full Code Here


                        col.update(QueryBuilder.start(getPROP_PATH()).is(changed.getProperties().get(getPROP_PATH())).get(),
                                changed.getProperties());
                        this.context.notifyUpdated(info);
                    } else {
                        // create
                        col.save(changed.getProperties());
                        this.context.notifyUpdated(info);
                    }
                } else {
                    throw new PersistenceException("Unable to create collection " + changed.getCollection(), null, changed.getPath(), null);
                }
View Full Code Here

    protected void doSave(Exchange exchange) throws Exception {
        DBCollection dbCol = calculateCollection(exchange);
        DBObject saveObj = exchange.getIn().getMandatoryBody(DBObject.class);

        WriteConcern wc = extractWriteConcern(exchange);
        WriteResult result = wc == null ? dbCol.save(saveObj) : dbCol.save(saveObj, wc);
        exchange.getIn().setHeader(MongoDbConstants.OID, saveObj.get("_id"));

        prepareResponseMessage(exchange, MongoDbOperation.save);
        // we always return the WriteResult, because whether the getLastError was called or not, the user will have the means to call it or
        // obtain the cached CommandResult
View Full Code Here

    protected void doSave(Exchange exchange) throws Exception {
        DBCollection dbCol = calculateCollection(exchange);
        DBObject saveObj = exchange.getIn().getMandatoryBody(DBObject.class);

        WriteConcern wc = extractWriteConcern(exchange);
        WriteResult result = wc == null ? dbCol.save(saveObj) : dbCol.save(saveObj, wc);
        exchange.getIn().setHeader(MongoDbConstants.OID, saveObj.get("_id"));

        prepareResponseMessage(exchange, MongoDbOperation.save);
        // we always return the WriteResult, because whether the getLastError was called or not, the user will have the means to call it or
        // obtain the cached CommandResult
View Full Code Here

    protected void doSave(Exchange exchange) throws Exception {
        DBCollection dbCol = calculateCollection(exchange);
        DBObject saveObj = exchange.getIn().getMandatoryBody(DBObject.class);

        WriteConcern wc = extractWriteConcern(exchange);
        WriteResult result = wc == null ? dbCol.save(saveObj) : dbCol.save(saveObj, wc);

        prepareResponseMessage(exchange, MongoDbOperation.save);
        // we always return the WriteResult, because whether the getLastError was called or not, the user will have the means to call it or
        // obtain the cached CommandResult
        processAndTransferWriteResult(result, exchange);
View Full Code Here

    protected void doSave(Exchange exchange) throws Exception {
        DBCollection dbCol = calculateCollection(exchange);
        DBObject saveObj = exchange.getIn().getMandatoryBody(DBObject.class);

        WriteConcern wc = extractWriteConcern(exchange);
        WriteResult result = wc == null ? dbCol.save(saveObj) : dbCol.save(saveObj, wc);

        prepareResponseMessage(exchange, MongoDbOperation.save);
        // we always return the WriteResult, because whether the getLastError was called or not, the user will have the means to call it or
        // obtain the cached CommandResult
        processAndTransferWriteResult(result, exchange);
View Full Code Here

        DBObject object = system.findOne();
        if (object == null) {
            object = new BasicDBObject();
        }
        object.put("next-id", Long.toString(serialNumber));
        system.save(object);
        LOG.info("serial number written: " + serialNumber);
    }

    private long readSerialNumber() {
        final DBCollection system = db.getCollection(SERIALNUMBERS_COLLECTION_NAME);
View Full Code Here

          .append("id", event.getID())
          .append("time", event.getTime())
          .append("type", event.getType())
          .append("properties", event.getProperties());

      collection.save(dbObject);
    }
  }

  @Override
  public List<LogDescriptor> getDescriptors(String targetID)
View Full Code Here

    } else {
      genID = null;
    }
    DBCollection coll = db.getCollection(collection);
    DBObject obj = jsonToDBObject(doc);
    WriteResult res = coll.save(obj);
    if (res.getError() == null) {
      if (genID != null) {
        JsonObject reply = new JsonObject();
        reply.putString("_id", genID);
        sendOK(message, reply);
View Full Code Here

    protected void doSave(Exchange exchange) throws Exception {
        DBCollection dbCol = calculateCollection(exchange);
        DBObject saveObj = exchange.getIn().getMandatoryBody(DBObject.class);
       
        WriteConcern wc = extractWriteConcern(exchange);
        WriteResult result = wc == null ? dbCol.save(saveObj) : dbCol.save(saveObj, wc);
       
        prepareResponseMessage(exchange, MongoDbOperation.save);
        // we always return the WriteResult, because whether the getLastError was called or not, the user will have the means to call it or
        // obtain the cached CommandResult
        processAndTransferWriteResult(result, exchange);
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.