Skip to content
Permalink
Browse files

Add script to create the query view indexes.

  • Loading branch information...
albertosantini committed Jun 28, 2018
1 parent 2fc9cb1 commit e66af2b1fb3286b5ac3e52438c9b9d4d89da8edc
Showing with 30 additions and 50 deletions.
  1. +30 −50 support/couchDB.js
@@ -10,9 +10,9 @@ const util = require("../lib/util");
const request = util.request;

const cfg = {
url: "http://user1:pass1@x.y.com",
db: "dbName",
design: "_design/designDocName"
url: "http://localhost:5984",
db: "conpa",
design: "_design/ConPA"
};

function saveDesignDoc(rev) {
@@ -155,50 +155,30 @@ request({
}
});

// {
// "selector": {
// "perf": {
// "$gt": -42
// },
// "ref": {
// "$gt": "2018/01/01",
// "$lt": "2018/12/31"
// }
// },
// "fields": [
// "ref",
// "perf",
// "assets",
// "weights"
// ],
// "limit": 3,
// "sort": [
// {
// "perf": "asc"
// }
// ]
// }

// {
// "_id": "_design/0457ad76f1654d82190494ead6b2e33bc34fdabc",
// "_rev": "1-4d91c6637fa869bee2e672885961e8a1",
// "language": "query",
// "views": {
// "perf-json-index": {
// "map": {
// "fields": {
// "perf": "asc"
// },
// "partial_filter_selector": {}
// },
// "reduce": "_count",
// "options": {
// "def": {
// "fields": [
// "perf"
// ]
// }
// }
// }
// }
// }
function createIndex(indexName) {
request({
method: "POST",
url: "http://localhost:5984/conpa/_index",
body: {
index: {
fields: [
indexName
]
},
name: `${indexName}-json-index`,
type: "json"
}
}, (err, response, res) => {
if (!err) {
const doc = JSON.parse(res);

console.warn(doc.name, doc.result);
} else {
console.warn(err, res);
}
});
}

createIndex("perf");
createIndex("risk");
createIndex("ret");

0 comments on commit e66af2b

Please sign in to comment.
You can’t perform that action at this time.