Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/snowch/cloudant-java-query-examples
https://github.com/snowch/cloudant-java-query-examples
Last synced: about 5 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/snowch/cloudant-java-query-examples
- Owner: snowch
- Created: 2015-12-16T09:28:52.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-17T11:58:53.000Z (almost 9 years ago)
- Last Synced: 2023-08-08T02:16:04.305Z (over 1 year ago)
- Language: Java
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
A few test cases for Cloudant Java
--- Copy cloudant.properties_template to cloudant.properties
- Add your Cloudant credentials to cloudant.properties
- Create a database with the following documents:```
{
"_id": "68",
"name": "Peanut butter",
"title": "Peanut butter is the name",
"description": "Peanut butter is the description",
"prices": [
{
"storeName": "Morrisons",
"price": 97
},
{
"storeName": "Saintburrys",
"price": 72
},
{
"storeName": "Tesco",
"price": 79
}
],
"rev": null
}{
"_id": "69",
"name": "Beans",
"title": "Beans is the name",
"description": "Beans is the description",
"prices": [
{
"storeName": "The Health Food Shop",
"price": 97
}
],
"rev": null
}
```- Create views:
```
{
"_id": "_design/ddoc",
"_rev": "12-c8b90da86721e12b647e8bdb9ddf37ab",
"views": {
"find-by-product-name": {
"map": "function (doc) {
if (doc.name) {
emit(doc.name, null);
}
}"
},
"find-by-store-name": {
"map": "function (doc) {
var shop, price, storename,storeprice;
if (doc.name && doc.prices) {
for (shop in doc.prices) {
storename = doc.prices[shop].storeName;
storeprice = doc.prices[shop].price;
emit(storename, storeprice);
}
}
}"
}
},
"indexes": {
"find-by-store-name": {
"analyzer": "keyword",
"index": "function (doc) {
var shop, price, storename;
if (doc.name && doc.prices) {
for (shop in doc.prices) {
storename = doc.prices[shop].storeName;
index(\"storename\", storename, {\"store\": true});
}
}
}"
}
}
}
```- Run tests:
```
./gradlew check
```