Package repositories

Source Code of repositories.ShipperRepository

package repositories;

import org.ektorp.CouchDbConnector;
import org.ektorp.ViewResult;
import org.ektorp.support.CouchDbRepositorySupport;
import org.ektorp.support.View;
import org.ektorp.support.Views;

import pojo.Shipper;

@Views({
  @View( name = "all", map = "function(doc) { emit(null,doc._id)}"),
  @View( name = "id_sum", map = "function(doc) { emit(null,doc._id)}",
    reduce = "function(keys,values) {return sum(values)}"),
  @View( name = "random", map = "function(doc) { emit(doc._id, {CompanyName : doc.companyName, Phone : doc.phone})}")
})
public class ShipperRepository extends CouchDbRepositorySupport<Shipper> {

  public ShipperRepository(CouchDbConnector db) {
    super(Shipper.class,db);
    initStandardDesignDocument();
  }
 
  public int getIdSum() {
    ViewResult r = db.queryView(createQuery("id_sum"));
        return r.getRows().get(0).getValueAsInt();
  }

}
TOP

Related Classes of repositories.ShipperRepository

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.