Package jp.ameba.mongo.protocol

Examples of jp.ameba.mongo.protocol.Update


  @Test
  public void testUpdate() throws Exception {
   
    client.delete(new Delete("test", "update", new BasicBSONObject("_id", "updateId")));
    // Test null update
    client.update(new Update("test", "update",
        new BasicBSONObject("_id", "updateId"),
        new BasicBSONObject("name", "abcdefg")
    ));
    Response response = client.query(new Query("test", "update", 0, 1, new BasicBSONObject("_id", "updateId"), null));
    Assert.assertEquals(response.getNumberReturned(), 0);

    client.insert(new Insert("test", "update", new BasicBSONObject("_id", "updateId").append("name", "testname")));
    response = client.query(new Query("test", "update", 0, 1, new BasicBSONObject("_id", "updateId"), null));
    Assert.assertEquals(1, response.getNumberReturned());
   
    client.update(new Update("test", "update", new BasicBSONObject("_id", "updateId"), new BasicBSONObject("_id", "updateId").append("name", "testname updated")));
    response = client.query(new Query("test", "update", 0, 1, new BasicBSONObject("_id", "updateId"), null));
    Assert.assertEquals(1, response.getNumberReturned());
    BSONObject result = response.getDocuments().get(0);
   
    Assert.assertEquals("updateId", result.get("_id"));
View Full Code Here


  @Test
  public void testUpsert() throws Exception {
   
    client.delete(new Delete("test", "update", new BasicBSONObject("_id", "updateId")));
   
    Update update = new Update("test", "update",
        new BasicBSONObject("_id", "updateId"),
        new BasicBSONObject()
          .append("_id", "updateId")
          .append("name", "test-name")
          .append("num", 100)
View Full Code Here

  @Override
  public void update(BSONObject selector, BSONObject document,
      Consistency consistency) {
    client.getConnection().update(
        new Update(
            databaseName,
            collectionName,
            selector,
            document
        ).consistency(consistency)
View Full Code Here

  @Override
  public void upsert(BSONObject selector, BSONObject document,
      Consistency consistency) {
    client.getConnection().update(
        new Update(
            databaseName,
            collectionName,
            selector,
            document
        ).consistency(consistency).upsert()
View Full Code Here

TOP

Related Classes of jp.ameba.mongo.protocol.Update

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.