rethinkdb-elasticsearch-stream
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -25,7 +25,8 @@ 'use strict'; | ||
* @param {String} db The database in RethinkDB to duplicate | ||
* @param {String} esType The Elasticsearch type to store the document (defaults to RedthinkDB table name) | ||
* @param {String} table The table in RethinkDB to duplicate | ||
*/ | ||
function backfillTable(r, _ref) { | ||
let { db, table } = _ref, | ||
properties = _objectWithoutProperties(_ref, ['db', 'table']); | ||
let { db, esType, table } = _ref, | ||
properties = _objectWithoutProperties(_ref, ['db', 'esType', 'table']); | ||
@@ -41,3 +42,3 @@ return new Promise((resolve, reject) => { | ||
document: chunk, | ||
table | ||
table: esType || table | ||
}, properties)); | ||
@@ -44,0 +45,0 @@ } catch (e) { |
@@ -11,2 +11,3 @@ 'use strict'; | ||
* @param {Object} document The document to save. This may be transformed by `transform`. | ||
* @param {String} esType The Elasticsearch type where the document will be stored (defaults to RethinkDB table name) | ||
* @param {String} table The table in RethinkDB the document resides in (used as Elasticsearch type) | ||
@@ -20,2 +21,3 @@ * @param {Function} transform (optional) A function or promise to transform the document before storage in Elasticsearch | ||
document, | ||
esType, | ||
idKey, | ||
@@ -28,16 +30,8 @@ table, | ||
if (documentToSave == null) return; | ||
if (Object.keys(documentToSave).length === 0) return; | ||
const path = (0, _elasticsearchPath2.default)({ | ||
db, | ||
id: idKey ? documentToSave[idKey] : null, | ||
table | ||
}); | ||
if (idKey) { | ||
return _axios2.default.put(path, documentToSave, { baseURL }); | ||
if (Array.isArray(documentToSave)) { | ||
return Promise.all(documentToSave.map(function (d) { | ||
return pushDocument(baseURL, db, d, idKey, esType || table); | ||
})); | ||
} | ||
return _axios2.default.post(path, documentToSave, { baseURL }); | ||
return pushDocument(baseURL, db, documentToSave, idKey, esType || table); | ||
}); | ||
@@ -62,2 +56,19 @@ | ||
function pushDocument(baseURL, db, doc, idKey, table) { | ||
if (doc == null) return; | ||
if (Object.keys(doc).length === 0) return; | ||
const path = (0, _elasticsearchPath2.default)({ | ||
db, | ||
id: idKey ? doc[idKey] : null, | ||
table | ||
}); | ||
if (idKey) { | ||
return _axios2.default.put(path, doc, { baseURL }); | ||
} | ||
return _axios2.default.post(path, doc, { baseURL }); | ||
} | ||
exports.default = saveDocument; |
{ | ||
"name": "rethinkdb-elasticsearch-stream", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "build/index.js", | ||
@@ -31,3 +31,3 @@ "repository": "https://github.com/gsandf/rethinkdb-elasticsearch-stream", | ||
"scripts": { | ||
"build": "babel src --out-dir build --ignore '**/*.test.js' --ignore 'test-helpers/'", | ||
"build": "babel src --out-dir build --ignore *.test.js,test-helpers", | ||
"container": "docker-compose run app", | ||
@@ -40,3 +40,3 @@ "coverage": "nyc ava", | ||
"start": "node .", | ||
"test": "ava", | ||
"test": "ava src/**/*.test.js", | ||
"test:container": "docker-compose build && docker-compose run app yarn test -- -v; docker-compose down" | ||
@@ -43,0 +43,0 @@ }, |
@@ -10,3 +10,3 @@ # rethinkdb-elasticsearch-stream | ||
** ✨ Features: ** | ||
**✨ Features:** | ||
@@ -78,6 +78,7 @@ - **Simple:** specify connections and tables to copy as-is to Elasticsearch | ||
With [npm](https://npmjs.org/) installed, run | ||
With [Yarn](https://yarnpkg.com/en/) _or_ [npm](https://npmjs.org/) installed, run: | ||
```bash | ||
yarn add rethinkdb-elasticsearch-stream | ||
# ...or, if using `npm` | ||
@@ -84,0 +85,0 @@ npm install rethinkdb-elasticsearch-stream |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
96
166413
21
364
1