Package com.mongodb

Examples of com.mongodb.BasicDBObject


      String.class);
  }

  @Override
  public List<User> fetchUsers(int page, int pageSize) {
    DBObject orderBy = new BasicDBObject("_id", -1);
    int skip = page * pageSize;
    return usersCollection.find().sort(orderBy).skip(skip).limit(pageSize).toArray();
  }
View Full Code Here


  }

  @Override
  public Optional<User> getBySessionToken(UUID sessionToken) {

    DBObject query = new BasicDBObject("sessionToken", sessionToken);
    User user = usersCollection.findOne(query);
    return Optional.fromNullable(user);
  }
View Full Code Here

    return Optional.fromNullable(user);
  }

  @Override
  public Optional<User> getByOpenIDIdentifier(String openIDIdentifier) {
    DBObject query = new BasicDBObject("openIDIdentifier", openIDIdentifier);
    User user = usersCollection.findOne(query);
    return Optional.fromNullable(user);
  }
View Full Code Here

    return Optional.fromNullable(user);
  }

  @Override
  public Optional<User> getByEmailAddress(String emailAddress) {
    DBObject query = new BasicDBObject("emailAddress", emailAddress);
    User user = usersCollection.findOne(query);
    return Optional.fromNullable(user);
  }
View Full Code Here

      String.class);
  }

  @Override
  public List<SoilData> fetchNewestSoilData(int page, int pageSize) {
    DBObject orderBy = new BasicDBObject("_id", -1);
    int skip = page * pageSize;
    return soilDataCollection.find().sort(orderBy).skip(skip).limit(pageSize).toArray();
  }
View Full Code Here

    mongodProcess = mongodExecutable.start();
    Mongo mongo = new Mongo("localhost", 12345);
    db = mongo.getDB(DATABASE_NAME);

    // Create collections
    db.createCollection("soilData", new BasicDBObject());

  }
View Full Code Here

  @Test
  public void shouldCreateNewObjectInEmbeddedMongoDb() {

    // 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

            final boolean deleted = this.deletedResources.remove(path);
            final MongoDBResource oldResource = (MongoDBResource)this.getResource(resolver, path, info);
            if ( !deleted && oldResource != null ) {
                throw new PersistenceException("Resource already exists at " + path, null, path, null);
            }
            final DBObject dbObj = new BasicDBObject();
            dbObj.put(getPROP_PATH(), info[1]);
            if ( properties != null ) {
                for(Map.Entry<String, Object> entry : properties.entrySet()) {
                    final String key = propNameToKey(entry.getKey());
                    dbObj.put(key, entry.getValue());
                }
            }
            if ( deleted && oldResource != null ) {
                dbObj.put(PROP_ID, oldResource.getProperties().get(PROP_ID));
            }
            final MongoDBResource rsrc = new MongoDBResource(resolver, path, info[0], dbObj, this);
            this.changedResources.put(path, rsrc);

            return rsrc;
View Full Code Here

    }
   
    World[] worlds = new World[queries];
    for (int i = 0; i < queries; i++) {
      DBObject object = database.getCollection("World").findOne(
          new BasicDBObject("_id", Helper.randomWorld()));
      worlds[i] = new World(
          //
          // The creation script for the Mongo database inserts these numbers as
          // JavaScript numbers, which resolve to Doubles in Java.
          //
View Full Code Here

    }
    int queries = Helper.getQueries(exchange);
    World[] worlds = new World[queries];
    for (int i = 0; i < queries; i++) {
      int id = Helper.randomWorld();
      DBObject key = new BasicDBObject("_id", id);
      //
      // The requirements for the test dictate that we must fetch the World
      // object from the data store and read its randomNumber field, even though
      // we could technically avoid doing either of those things and still
      // produce the correct output and side effects.
View Full Code Here

TOP

Related Classes of com.mongodb.BasicDBObject

Copyright © 2018 www.massapicom. 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.