Package com.mongodb

Examples of com.mongodb.DBObject.keySet()


        obj = collection.findOne(json("foo:'bar'"), json("_id: 1"));
        assertThat(obj.keySet()).containsOnly("_id");

        obj = collection.findOne(json("foo: 'bar'"), json("_id: 0, foo:1"));
        assertThat(obj.keySet()).containsOnly("foo");
    }

    @Test
    public void testQueryWithDotNotationFieldSelector() throws Exception {
        collection.insert(json("_id: 123, index: false, foo: { a: 'a1', b: 0}"));
View Full Code Here


        final DBCollection instances = testDb.getCollection(SPEC_NAME);
        assertEquals(1, instances.getCount());
        final DBObject object = instances.findOne();
        assertNotNull(object.get("_id"));
        assertEquals("D01", object.get("_id"));
        assertEquals(1, object.keySet().size());
    }

    @Test
    public void writeFields() throws Exception {
        writer.writeType(SPEC_NAME);
View Full Code Here

            dboUpdate = col.findAndModify(query,fields,new BasicDBObject(),false,updateOp,false,true)
              // (can use findAndModify because specify index, ie the shard key)
              // (returns event before the changes above, update the feature object below)
              // (also atomically creates the object if it doesn't exist so is "distributed-safe")
          }
          if ( ( dboUpdate != null ) && !dboUpdate.keySet().isEmpty() )
          {
            AssociationFeaturePojo egp = AssociationFeaturePojo.fromDb(dboUpdate, AssociationFeaturePojo.class);
            evtFeature.setDoccount(egp.getDoccount() + nSavedDocCount);
            evtFeature.setDb_sync_doccount(egp.getDb_sync_doccount());
            evtFeature.setDb_sync_time(egp.getDb_sync_time());
View Full Code Here

              dboUpdate = col.findAndModify(query, fields, new BasicDBObject(), false, updateOp, false, true);
                // (can use findAndModify because specify index, ie the shard key)
                // (returns entity before the changes above, update the feature object below)
                // (also atomically creates the object if it doesn't exist so is "distributed-safe")
            }
            if ( ( dboUpdate != null ) && !dboUpdate.keySet().isEmpty() ) // (feature already exists)
            {
              // (Update the entity feature to be correct so that it can be accurately synchronized with the index)             
              EntityFeaturePojo gp = EntityFeaturePojo.fromDb(dboUpdate, EntityFeaturePojo.class);
              entFeature.setTotalfreq(gp.getTotalfreq() + nSavedFreqCount);
              entFeature.setDoccount(gp.getDoccount() + nSavedDocCount);
View Full Code Here

            cmd.append("query", query);
        }
        if (fields != null && !fields.keySet().isEmpty()) {
            cmd.append("fields", fields);
        }
        if (sort != null && !sort.keySet().isEmpty()) {
            cmd.append("sort", sort);
        }

        if (remove) {
            cmd.append("remove", remove);
View Full Code Here

                return db.getName();
            }

            @Override
            public String getShortName() {
                return cmd.keySet().iterator().next();
            }

        }.addJob();
    }
View Full Code Here

    @Override
    protected void structureComponentCustom(BoxPanel old) {
        Div fields = (Div) getBoundUnit(Item.fields);
        fields.removeAllChildren();
        DBObject doc = (DBObject) value;
        if (doc == null || doc.keySet().isEmpty()) {
            fields.addChild(new Text(null, null, "Empty"));
        } else {
            for (String key : doc.keySet()) {
                Object val = doc.get(key);
                if (val instanceof BasicDBObject) {
View Full Code Here

        fields.removeAllChildren();
        DBObject doc = (DBObject) value;
        if (doc == null || doc.keySet().isEmpty()) {
            fields.addChild(new Text(null, null, "Empty"));
        } else {
            for (String key : doc.keySet()) {
                Object val = doc.get(key);
                if (val instanceof BasicDBObject) {
                    fields.addChild(new DocFieldObject(key, key, val, this));
                } else if (val instanceof BasicDBList) {
                    fields.addChild(new DocFieldArray(key, key, val, this));
View Full Code Here

    }

    void moveUp(String key) {
        DBObject doc = (DBObject) value;
        value = createDBObject();
        Iterator<String> it = doc.keySet().iterator();
        String prev = it.next();
        while (it.hasNext()) {
            String cur = it.next();
            if (cur.equals(key)) {
                addField(cur, doc.get(cur));
View Full Code Here

    }

    void moveDown(String key) {
        DBObject doc = (DBObject) value;
        value = createDBObject();
        Iterator<String> it = doc.keySet().iterator();
        while (it.hasNext()) {
            String cur = it.next();
            if (cur.equals(key) && it.hasNext()) {
                String next = it.next();
                addField(next, doc.get(next));
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.