本文整理汇总了Java中com.couchbase.client.java.query.N1qlQuery.parameterized方法的典型用法代码示例。如果您正苦于以下问题:Java N1qlQuery.parameterized方法的具体用法?Java N1qlQuery.parameterized怎么用?Java N1qlQuery.parameterized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.couchbase.client.java.query.N1qlQuery
的用法示例。
在下文中一共展示了N1qlQuery.parameterized方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import com.couchbase.client.java.query.N1qlQuery; //导入方法依赖的package包/类
public Cart get(String cartId) {
N1qlParams params = N1qlParams.build().adhoc(false).consistency(ScanConsistency.STATEMENT_PLUS);
JsonObject values = JsonObject.create().put("id", cartId);
N1qlQuery query = N1qlQuery.parameterized("select "+ cartBucketName + ".* from `" + cartBucketName + "` where docType='"+ DocTypes.CartAggregateView.name() +"' and id=$id", values, params);
List<Cart> carts = db.getBucket().async().query(query)
.flatMap(AsyncN1qlQueryResult::rows)
.map(result -> {
return createObject(result.value().toString());
})
.toList()
.timeout(10, TimeUnit.SECONDS)
.toBlocking()
.single();
if(carts.isEmpty()) {
return null;
} else {
return carts.get(0);
}
}
示例2: getCartEvents
import com.couchbase.client.java.query.N1qlQuery; //导入方法依赖的package包/类
public List<Event> getCartEvents(String cartId, long snapshotEventSequenceNumber) {
N1qlParams params = N1qlParams.build().adhoc(false).consistency(ScanConsistency.STATEMENT_PLUS);
JsonObject values = JsonObject.create().put("cartId", cartId)
.put("snapshotEventNumber", snapshotEventSequenceNumber);
N1qlQuery query = N1qlQuery.parameterized("select "+ eventBucketName +".* from `"+ eventBucketName +"` where docType='CartEvent' and cartId=$cartId and eventNumber > $snapshotEventNumber order by eventNumber", values, params);
List<Event> events = db.getBucket().async().query(query)
.flatMap(AsyncN1qlQueryResult::rows)
.map(result -> {
return createEvent(result.value().toString());
})
.toList()
.timeout(10, TimeUnit.SECONDS)
.toBlocking()
.single();
return events;
}
示例3: get
import com.couchbase.client.java.query.N1qlQuery; //导入方法依赖的package包/类
public Cart get(String cartId) {
N1qlParams params = N1qlParams.build().adhoc(false).consistency(ScanConsistency.STATEMENT_PLUS);
JsonObject values = JsonObject.create().put("id", cartId);
N1qlQuery query = N1qlQuery.parameterized("select "+ cartBucketName + ".* from `" + cartBucketName + "` where docType='" + DocTypes.CartQueryView.name()+ "' and id=$id", values, params);
List<Cart> carts = db.getBucket().async().query(query)
.flatMap(AsyncN1qlQueryResult::rows)
.map(result -> {
return createObject(result.value().toString());
})
.toList()
.timeout(10, TimeUnit.SECONDS)
.toBlocking()
.single();
if(carts.isEmpty()) {
return null;
} else {
return carts.get(0);
}
}
示例4: searchDevelopers
import com.couchbase.client.java.query.N1qlQuery; //导入方法依赖的package包/类
@ResponseBody
@RequestMapping("/developer/search")
public String searchDevelopers(final @RequestParam("firstname") String firstName, final @RequestParam("lastname") String lastName) throws Exception {
String statement = "SELECT developer.* FROM `" + bucket.name() + "` AS developer WHERE developer.type = 'developer'";
JsonObject params = JsonObject.create();
if (!firstName.equals("")) {
params.put("firstName", firstName.toLowerCase() + "%");
statement += " AND lower(developer.developerInfo.firstName) LIKE $firstName";
}
if (!lastName.equals("")) {
params.put("lastName", lastName.toLowerCase() + "%");
statement += " AND lower(developer.developerInfo.lastName) LIKE $lastName";
}
N1qlQuery developerByEmail = N1qlQuery.parameterized(statement, params);
return rawQueryExecutor.n1qlToRawJson(developerByEmail);
}
示例5: developer
import com.couchbase.client.java.query.N1qlQuery; //导入方法依赖的package包/类
@ResponseBody
@RequestMapping("/developer/fullcontact/{developerId}")
public String developer(final @PathVariable String developerId) throws Exception {
JsonArray params = JsonArray.create();
params.add(developerId);
N1qlQuery developerWithContacts = N1qlQuery.parameterized("SELECT customer.*, (SELECT contact.* FROM `" + bucket.name() + "` AS contact USE KEYS customer.contacts) AS contacts, (SELECT ticket.* FROM `" + bucket.name() + "` AS ticket USE KEYS customer.history) AS history FROM `" + bucket.name() + "` AS customer WHERE customer.type = 'developer' AND customer.id = $1", params);
return rawQueryExecutor.n1qlToRawJson(developerWithContacts);
}
示例6: getDeveloperContact
import com.couchbase.client.java.query.N1qlQuery; //导入方法依赖的package包/类
@ResponseBody
@RequestMapping("/developer/contacts/{contactId}")
public String getDeveloperContact(final @PathVariable String contactId) throws Exception {
JsonArray params = JsonArray.create();
params.add(contactId);
N1qlQuery developerWithContacts = N1qlQuery.parameterized("SELECT " +
"(SELECT contact.* FROM `" + bucket.name() + "` AS contact USE KEYS customer.contacts) AS contacts, " +
"(SELECT ticket.* FROM `" + bucket.name() + "` AS ticket USE KEYS customer.history) AS tickets " +
"FROM `" + bucket.name() + "` AS customer " +
"WHERE customer.type = 'developer' AND customer.id = $1", params);
return rawQueryExecutor.n1qlToRawJson(developerWithContacts);
}
示例7: getCustomerByEmail
import com.couchbase.client.java.query.N1qlQuery; //导入方法依赖的package包/类
@ResponseBody
@RequestMapping("/developer/getByEmail")
public String getCustomerByEmail(final @RequestParam("email") String email) throws Exception {
JsonArray params = JsonArray.create();
params.add(email);
N1qlQuery developerByEmail = N1qlQuery.parameterized("SELECT customer.* " +
"FROM `" + bucket.name() + "` AS customer " +
"WHERE customer.type = 'developer' AND customer.developerInfo.email = $1", params);
return rawQueryExecutor.n1qlToRawJson(developerByEmail);
}
示例8: getTicket
import com.couchbase.client.java.query.N1qlQuery; //导入方法依赖的package包/类
@ResponseBody
@RequestMapping("/developer/tickets/{developerId}")
public String getTicket(final @PathVariable String developerId) throws Exception {
JsonArray params = JsonArray.create();
params.add(developerId);
N1qlQuery developerWithContacts = N1qlQuery.parameterized("SELECT (SELECT ticket.* FROM `" + bucket.name() + "` AS ticket USE KEYS customer.history) AS history FROM `" + bucket.name() + "` AS customer WHERE customer.type = 'developer' AND customer.id = $1", params);
return rawQueryExecutor.n1qlToRawJson(developerWithContacts);
}
示例9: find
import com.couchbase.client.java.query.N1qlQuery; //导入方法依赖的package包/类
public Page<T> find(Parameters params, Pageable pageable, Class<T> clazz) {
CouchbaseTemplate template = createTemplate();
Statement query = createQueryStatement(params, pageable);
N1qlQuery queryWithParameter = N1qlQuery.parameterized(query, params.toJsonObject());
List<T> data = convertToDataList(template.findByN1QLProjection(queryWithParameter, LinkedHashMap.class), clazz);
Integer count = count(params);
return new PageImpl<>(data, pageable, count);
}
示例10: count
import com.couchbase.client.java.query.N1qlQuery; //导入方法依赖的package包/类
public Integer count(Parameters params) {
CouchbaseTemplate template = createTemplate();
Statement query = createCountStatement(params);
N1qlQuery queryWithParams = N1qlQuery.parameterized(query, params.toJsonObject());
LinkedHashMap countMap = ((LinkedHashMap) template.findByN1QLProjection(queryWithParams, Object.class).get(0));
return ((Integer) countMap.get("count"));
}
示例11: sum
import com.couchbase.client.java.query.N1qlQuery; //导入方法依赖的package包/类
public Integer sum(Parameters params, String field) {
CouchbaseTemplate template = createTemplate();
Statement query = createSumStatement(params, field);
N1qlQuery queryWithParams = N1qlQuery.parameterized(query, params.toJsonObject());
LinkedHashMap sumMap = ((LinkedHashMap) template.findByN1QLProjection(queryWithParams, Object.class).get(0));
return ((Integer) sumMap.get("sum"));
}