Package com.mongodb

Examples of com.mongodb.DBCollection.save()


                    List<DBObject> batch = new ArrayList<DBObject>();
                    while ((obj = dd.readObject()) != null) {
                        try {
                            if (upsert) {
                                if (upsertFields == null) {
                                    col.save(obj);
                                } else {
                                    BasicDBObject query = new BasicDBObject();
                                    for (int i = 0; i < upsertFields.length; ++i) {
                                        String field = upsertFields[i];
                                        if (!obj.containsField(field)) {
View Full Code Here


       
        new DbJob() {

            @Override
            public Object doRun() {
                return col.save(doc);
            }

            @Override
            public String getNS() {
                return ns;
View Full Code Here

        new DbJob() {

            @Override
            public Object doRun() throws IOException {
                return col.save(newUser);
            }

            @Override
            public String getNS() {
                return col.getName();
View Full Code Here

        shifter.setMainShape(new Circle(2.2));
        shifter.getAvailableShapes().add(new Rectangle(3,3));
        shifter.getAvailableShapes().add(new Circle(4.4));

        DBObject shifterDbObj = morphia.toDBObject(shifter);
        shapeshifters.save(shifterDbObj);

        BasicDBObject shifterDbObjLoaded = (BasicDBObject) shapeshifters.findOne(new BasicDBObject(Mapper.ID_KEY, shifterDbObj.get(Mapper.ID_KEY)));
    ShapeShifter shifterLoaded = morphia.fromDBObject(ShapeShifter.class, shifterDbObjLoaded, new DefaultEntityCache());

        assertNotNull(shifterLoaded);
View Full Code Here

            o.put("value", BSONWritable.toBSON(value));
        }

        try {
            DBCollection dbCollection = getDbCollectionByRoundRobin();
            dbCollection.save(o);
        } catch (final MongoException e) {
            throw new IOException("can't write to mongo", e);
        }
    }
View Full Code Here

            o.put("value", BSONWritable.toBSON(value));
        }

        try {
            DBCollection dbCollection = getDbCollectionByRoundRobin();
            dbCollection.save(o);
        } catch (final MongoException e) {
            throw new IOException("can't write to mongo", e);
        }

    }
View Full Code Here

  private void createGroupByData() {

    DBCollection c = mongoTemplate.getDb().getCollection("group_test_collection");

    c.save(new BasicDBObject("x", 1));
    c.save(new BasicDBObject("x", 1));
    c.save(new BasicDBObject("x", 2));
    c.save(new BasicDBObject("x", 3));
    c.save(new BasicDBObject("x", 3));
    c.save(new BasicDBObject("x", 3));
View Full Code Here

  private void createGroupByData() {

    DBCollection c = mongoTemplate.getDb().getCollection("group_test_collection");

    c.save(new BasicDBObject("x", 1));
    c.save(new BasicDBObject("x", 1));
    c.save(new BasicDBObject("x", 2));
    c.save(new BasicDBObject("x", 3));
    c.save(new BasicDBObject("x", 3));
    c.save(new BasicDBObject("x", 3));
  }
View Full Code Here

    DBCollection c = mongoTemplate.getDb().getCollection("group_test_collection");

    c.save(new BasicDBObject("x", 1));
    c.save(new BasicDBObject("x", 1));
    c.save(new BasicDBObject("x", 2));
    c.save(new BasicDBObject("x", 3));
    c.save(new BasicDBObject("x", 3));
    c.save(new BasicDBObject("x", 3));
  }
}
View Full Code Here

    DBCollection c = mongoTemplate.getDb().getCollection("group_test_collection");

    c.save(new BasicDBObject("x", 1));
    c.save(new BasicDBObject("x", 1));
    c.save(new BasicDBObject("x", 2));
    c.save(new BasicDBObject("x", 3));
    c.save(new BasicDBObject("x", 3));
    c.save(new BasicDBObject("x", 3));
  }
}
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.