Package com.mongodb

Examples of com.mongodb.DBCollection.update()


                for (String key : keys) {
                    cachedDocs.put(key, nodesCache.getIfPresent(new StringValue(key)));
                }
            }
            try {
                WriteResult writeResult = dbCollection.update(query.get(), update, false, true, WriteConcern.SAFE);
                if (writeResult.getError() != null) {
                    throw new MicroKernelException("Update failed: " + writeResult.getError());
                }
                // update cache
                for (Entry<String, NodeDocument> entry : cachedDocs.entrySet()) {
View Full Code Here


                for (String key : keys) {
                    cachedDocs.put(key, nodesCache.getIfPresent(key));
                }
            }
            try {
                WriteResult writeResult = dbCollection.update(query.get(), update, false, true, WriteConcern.SAFE);
                if (writeResult.getError() != null) {
                    throw new MicroKernelException("Update failed: " + writeResult.getError());
                }
                // update cache
                for (Entry<String, NodeDocument> entry : cachedDocs.entrySet()) {
View Full Code Here

        update = removeAssociationRowKey( assocSnapshot, rowKey, associationField );
        break;
      }

      if ( update != null ) {
        collection.update( query, update, true, false );
      }
    }
  }

  @Override
View Full Code Here

                for (String key : keys) {
                    cachedDocs.put(key, nodesCache.getIfPresent(new StringValue(key)));
                }
            }
            try {
                WriteResult writeResult = dbCollection.update(query.get(), update, false, true, WriteConcern.SAFE);
                if (writeResult.getError() != null) {
                    throw new MicroKernelException("Update failed: " + writeResult.getError());
                }
                if (collection == Collection.NODES) {
                    // update cache
View Full Code Here

    DBCollection table = info.getDbObj();
    DBObject row = table.findOne(action.getRowKey());
    BasicDBObject docToRemove = new BasicDBObject();
    docToRemove.put(StandardConverters.convertToString(action.getColumn()), 1);
    if (row != null)
      table.update(row, new BasicDBObject("$unset", docToRemove));
  }

  private void persist(Persist action, MetaLookup ormSession) {
    String colFamily = action.getColFamily().getColumnFamily();
    Info info = lookupOrCreate2(colFamily, ormSession);
View Full Code Here

      byte[] value = new byte[0];
      if(col.getValue() != null)
        value = col.getValue();
      doc.append(StandardConverters.convertToString(col.getName()), value);
    }
    table.update(row, new BasicDBObject("$set", doc));
  }

  public BasicDBObject findOrCreateRow(DBCollection table, byte[] key) {
    DBObject row = table.findOne(key);
    if(row == null) {
View Full Code Here

          MongoDatabase.FLD_SCHEMA_BASE, getIdOrZero(schema.getBase()),
          MongoDatabase.FLD_SCHEMA_ATTRIBS,
          attributeDefinitions(schema.getAttributeDefinitions()),
          MongoDatabase.FLD_SCHEMA_SERIES,
          seriesDefinitions(schema.getSeriesDefinitions()));
      coll.update(asQuery(s.getId()), operation, false, false, WriteConcern.SAFE);
      database.sleep();
      try {
        policy.willUpdate(schema);
      } catch (T2DBException e) {
        // Oops! referential integrity broken!
View Full Code Here

        operation = mongoObject(
            MongoDatabase.FLD_SCHEMA_NAME, original.getName(),
            MongoDatabase.FLD_SCHEMA_BASE, getId(original.getBase()),
            MongoDatabase.FLD_SCHEMA_ATTRIBS, original.getAttributeDefinitions(),
            MongoDatabase.FLD_SCHEMA_SERIES, original.getSeriesDefinitions());
        coll.update(asQuery(s.getId()), operation);
        throw e;
      }
      done = true;
    } catch (Exception e) {
      cause = e;
View Full Code Here

                String tmpKey = keys.next();
                fieldsToSet.put(tmpKey, values.get(tmpKey).toArray());

            }
            u.put("$set", fieldsToSet);
            WriteResult res = collection.update(q, u, false, false,
                    writeConcern);
            return res.getN() == 1 ? 0 : 1;
        }
        catch (Exception e) {
            System.err.println(e.toString());
View Full Code Here

        if (value instanceof MongoUpdateWritable) {
            //ignore the key - just use the update directly.
            MongoUpdateWritable muw = (MongoUpdateWritable) value;
            try {
                DBCollection dbCollection = getDbCollectionByRoundRobin();
                dbCollection.update(new BasicDBObject(muw.getQuery()), new BasicDBObject(muw.getModifiers()), muw.isUpsert(),
                                    muw.isMultiUpdate());
                return;
            } catch (final MongoException e) {
                throw new IOException("can't write to mongo", e);
            }
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.