Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rethinkdb-elasticsearch-stream

Package Overview
Dependencies
Maintainers
6
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rethinkdb-elasticsearch-stream - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

19

build/save-document.js

@@ -7,2 +7,4 @@ 'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
/**

@@ -20,11 +22,24 @@ * Replicate a document in Elasticsearch

db,
deleteTransform,
document,
esType,
idKey,
oldDocument,
table,
transform
}) {
// Transform the document if necessary
const documentToSave = transform != null ? yield transform({ db, document, table }) : document;
let documentToSave;
// document will be null if the doc was deleted in Rethink
if (document === null) {
documentToSave = deleteTransform != null ? yield deleteTransform({ db, document, oldDocument, table })
// if a deleteTransform isn't provided, the default behavior is to just
// delete the document from elastic search
: _extends({}, oldDocument, {
_delete: _._delete
});
} else {
documentToSave = transform != null ? yield transform({ db, document, oldDocument, table }) : document;
}
if (Array.isArray(documentToSave)) {

@@ -31,0 +46,0 @@ return Promise.all(documentToSave.map(function (d) {

3

build/watch-table.js

@@ -34,3 +34,3 @@ 'use strict';

return dataStream.pipe((0, _through.obj)((() => {
var _ref2 = _asyncToGenerator(function* ({ new_val: chunk }, enc, cb) {
var _ref2 = _asyncToGenerator(function* ({ new_val: chunk, old_val: oldDocument }, enc, cb) {
try {

@@ -40,2 +40,3 @@ yield (0, _saveDocument2.default)(_extends({

document: chunk,
oldDocument,
table

@@ -42,0 +43,0 @@ }, properties));

{
"name": "rethinkdb-elasticsearch-stream",
"version": "1.2.0",
"version": "2.0.0",
"main": "build/index.js",

@@ -5,0 +5,0 @@ "repository": "https://github.com/gsandf/rethinkdb-elasticsearch-stream",

@@ -63,2 +63,21 @@ # rethinkdb-elasticsearch-stream

db: 'megacorp',
// (optional) Handle when a document is deleted in Rethink
// This is detected when the new value for a document is null
// If this is not specified, a DELETE is sent to Elasticsearch for the
// id of the old value
deleteTransform: async ({db, document, oldDocument, table }) => {
if (await someImportantCheck()) {
return oldDocument;
}
// this is the default behavior for a delete
return {
// import { _delete } from 'rethinkdb-elasticsearch-stream';
//
// this is a special Symbol that tells the library that this should
// be a DELETE. It can also be used in the regular transform function
_delete
id: oldDocument.id,
}
},
// (optional) Type field for Elasticsearch. This is similar to a "table" in

@@ -77,5 +96,5 @@ // RethinkDB, and is the second portion of the URL path (index/db is the first).

// `db` and `table` are specified for convenience
transform: async ({ db, document, table }) => {
transform: async ({ db, document, oldDocument, table }) => {
await doSomethingImportant()
return document
return document;
}

@@ -82,0 +101,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc