當前位置: 首頁>>代碼示例>>Java>>正文


Java Datastore.find方法代碼示例

本文整理匯總了Java中org.mongodb.morphia.Datastore.find方法的典型用法代碼示例。如果您正苦於以下問題:Java Datastore.find方法的具體用法?Java Datastore.find怎麽用?Java Datastore.find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.mongodb.morphia.Datastore的用法示例。


在下文中一共展示了Datastore.find方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getUniqueMissingArtifacts

import org.mongodb.morphia.Datastore; //導入方法依賴的package包/類
public Collection<String> getUniqueMissingArtifacts() {
	Set<String> list = new HashSet<String>();
	Datastore ds = getDataSource();
	Query<ArtifactsData> q = ds.find(ArtifactsData.class);
	List<ArtifactsData> dataList = q.asList();
	
	for(ArtifactsData data : dataList) {
		list.add(data.getGroupId() + ":" + data.getArtifactId());
	}
	return list;
}
 
開發者ID:eBay,項目名稱:ostara,代碼行數:12,代碼來源:TelemetryDAO.java

示例2: getDatabyTaskId

import org.mongodb.morphia.Datastore; //導入方法依賴的package包/類
public TelemetryData getDatabyTaskId(String taskId) {
	Datastore ds = getDataSource();
	Query<TelemetryData> q = ds.find(TelemetryData.class, "taskId", taskId);
	TelemetryData td = null;
	if(q.asList().size() > 0) {
		td = q.get();
	}
	return td;
}
 
開發者ID:eBay,項目名稱:ostara,代碼行數:10,代碼來源:TelemetryDAO.java

示例3: getAllData

import org.mongodb.morphia.Datastore; //導入方法依賴的package包/類
public List<TelemetryData> getAllData() {
	Datastore ds = getDataSource();
	Query<TelemetryData> q = ds.find(TelemetryData.class);
	List<TelemetryData> dataList = q.asList();
	return dataList;
}
 
開發者ID:eBay,項目名稱:ostara,代碼行數:7,代碼來源:TelemetryDAO.java

示例4: getDataByAttribute

import org.mongodb.morphia.Datastore; //導入方法依賴的package包/類
public List<TelemetryData> getDataByAttribute(String key, String value) {
	Datastore ds = getDataSource();
	Query<TelemetryData> q = ds.find(TelemetryData.class, key, value);
	List<TelemetryData> dataList = q.asList();
	return dataList;
}
 
開發者ID:eBay,項目名稱:ostara,代碼行數:7,代碼來源:TelemetryDAO.java

示例5: getAllMissingArtifacts

import org.mongodb.morphia.Datastore; //導入方法依賴的package包/類
public List<ArtifactsData> getAllMissingArtifacts() {
	Datastore ds = getDataSource();
	Query<ArtifactsData> q = ds.find(ArtifactsData.class);
	List<ArtifactsData> dataList = q.asList();		
	return dataList;
}
 
開發者ID:eBay,項目名稱:ostara,代碼行數:7,代碼來源:TelemetryDAO.java

示例6: getMissingArtifactsByTaskId

import org.mongodb.morphia.Datastore; //導入方法依賴的package包/類
public List<ArtifactsData> getMissingArtifactsByTaskId(String taskId) {
	Datastore ds = getDataSource();
	Query<ArtifactsData> q = ds.find(ArtifactsData.class, "taskId", taskId);
	return q.asList();
}
 
開發者ID:eBay,項目名稱:ostara,代碼行數:6,代碼來源:TelemetryDAO.java

示例7: main

import org.mongodb.morphia.Datastore; //導入方法依賴的package包/類
public static void main(final String[] args) throws UnknownHostException {
    final Morphia morphia = new Morphia();

    // tell morphia where to find your classes
    // can be called multiple times with different packages or classes
    morphia.mapPackage("org.mongodb.morphia.example");

    // create the Datastore connecting to the database running on the default port on the local host
    final Datastore datastore = morphia.createDatastore(new MongoClient(), "morphia_example");
    datastore.getDB().dropDatabase();
    datastore.ensureIndexes();

    final Employee elmer = new Employee("Elmer Fudd", 50000.0);
    datastore.save(elmer);

    final Employee daffy = new Employee("Daffy Duck", 40000.0);
    datastore.save(daffy);

    final Employee pepe = new Employee("Pepé Le Pew", 25000.0);
    datastore.save(pepe);

    elmer.getDirectReports().add(daffy);
    elmer.getDirectReports().add(pepe);

    datastore.save(elmer);

    Query<Employee> query = datastore.find(Employee.class);
    final List<Employee> employees = query.asList();

    Assert.assertEquals(3, employees.size());

    List<Employee> underpaid = datastore.find(Employee.class)
                                        .filter("salary <=", 30000)
                                        .asList();
    Assert.assertEquals(1, underpaid.size());

    underpaid = datastore.find(Employee.class)
                         .field("salary").lessThanOrEq(30000)
                         .asList();
    Assert.assertEquals(1, underpaid.size());

    final Query<Employee> underPaidQuery = datastore.find(Employee.class)
                                                    .filter("salary <=", 30000);
    final UpdateOperations<Employee> updateOperations = datastore.createUpdateOperations(Employee.class)
                                                                 .inc("salary", 10000);

    final UpdateResults results = datastore.update(underPaidQuery, updateOperations);

    Assert.assertEquals(1, results.getUpdatedCount());

    final Query<Employee> overPaidQuery = datastore.find(Employee.class)
                                                   .filter("salary >", 100000);
    datastore.delete(overPaidQuery);
}
 
開發者ID:mongodb,項目名稱:morphia,代碼行數:55,代碼來源:QuickTour.java


注:本文中的org.mongodb.morphia.Datastore.find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。