Package com.mongodb

Examples of com.mongodb.DBObject.removeField()


            throws StandardCodedException {
        final DBObject filter = new BasicDBObject(_ID, id);
        // removeOne empty arrays
        final DBObject item = this.removeEmptyArrays(object);
        // removeOne _id for update of other fields
        item.removeField(_ID);
        final DBObject operation = new BasicDBObject("$set", item);
        // save
        return this.update(filter, operation, true, false);
        // object.put(_ID, id);    // add _id
    }
View Full Code Here


        assertThat(result.getN()).isEqualTo(1);

        DBObject object = collection.findOne();
        assertThat(result.getUpsertedId()).isEqualTo(object.get("_id"));

        object.removeField("_id");
        assertThat(object).isEqualTo(json("n:'jon', a:1"));

        result = collection.update(json("_id: 17, n:'jon'"), json("$inc:{a:1}"), true, false);
        assertThat(result.getUpsertedId()).isNull();
        assertThat(collection.findOne(json("_id:17"))).isEqualTo(json("_id: 17, n:'jon', a:1"));
View Full Code Here

    @Test
    public void testUpsertFieldOrder() throws Exception {
        collection.update(json("'x.y': 2"), json("$inc: {a:7}"), true, false);
        DBObject obj = collection.findOne();
        obj.removeField("_id");
        // this actually differs from the official MongoDB implementation
        assertThat(obj).isEqualTo(json("x:{y:2}, a:7"));
    }

    @Test
View Full Code Here

      BasicDBObject query = new BasicDBObject("_id",new ObjectId(shareIdStr));
      DBObject dboshare = DbManager.getSocial().getShare().findOne(query);
      if ( dboshare != null )
      {
        //write everything but binary
        dboshare.removeField("binaryData");
        SharePojo share = SharePojo.fromDb(dboshare, SharePojo.class);
        // Check ... am I the owner?
        ObjectId ownerId = new ObjectId(ownerIdStr);
        boolean bAdminOrModOfAllCommunities = RESTTools.adminLookup(ownerIdStr);
        if (!share.getOwner().get_id().equals(ownerId)) { // Then I have to be admin (except for one special case)
View Full Code Here

                convertedAwayFromMinMax = true;             
              }//TESTED
              // (else stick with min/max)
             
              if (convertedAwayFromMinMax) { // can construct an _id query
                splitQuery.removeField("$min");
                splitQuery.removeField("$max");
              }//TESTED
              splitQuery.put("$query", splitQueryQuery);
            }
            newsplits.add(new InfiniteMongoInputSplit(mongoSplit, conf.isNoTimeout()));
View Full Code Here

              }//TESTED
              // (else stick with min/max)
             
              if (convertedAwayFromMinMax) { // can construct an _id query
                splitQuery.removeField("$min");
                splitQuery.removeField("$max");
              }//TESTED
              splitQuery.put("$query", splitQueryQuery);
            }
            newsplits.add(new InfiniteMongoInputSplit(mongoSplit, conf.isNoTimeout()));
          }//TESTED     
View Full Code Here

            _collection.remove(_updatingReducer.getDeletionQuery());
          }
          if (null != reduceId) {
            o.put("_updateId", _updatingReducer.getReduceId()); // (so we know when this was last created)           
          }
          o.removeField("_id"); // (so will get re-created on save)
          _collection.save( o );
        }//TESTED
        else {
          // if we've found the object then we need to do a reduce on it:
          if (null == _updatingReducer && !_updatingReduceNotPossible) {
View Full Code Here

      } catch (ClassNotFoundException e) {
        throw new IOException(e);
      }

      // remove object ID from DBObject
      v.removeField("_id");
      value.set(v.toString().getBytes("UTF-8"));
      resultsRead++;
    }

    return hadMore;
View Full Code Here

        value = doc;
    }

    void remove(String key) {
        DBObject doc = (DBObject) value;
        doc.removeField(key);
        structureComponent();
    }

    void moveUp(String key) {
        DBObject doc = (DBObject) value;
View Full Code Here

        Object id = mapr.getId(entity);
        if (id == null)
            throw new MappingException("Could not get id for " + entity.getClass().getName());

        //remove (immutable) _id field for update.
        dbObj.removeField(Mapper.ID_KEY);

        WriteResult wr = null;

        MappedClass mc = mapr.getMappedClass(entity);
        DBCollection dbColl = getCollection(entity);
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.