
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
mongo-river-elastic
Advanced tools
https://www.npmjs.com/package/mongo-river-elastic The mongo-river-elastic project provides a nodejs wrapper over mongodb nodejs , which synchronize data from your mongodb to elasticsearch. It is tested and works best with following:
Following Mongodb functions are supported:
river during insert/update and it is indexed. This key stores timestamp and is used for syncing with elasticsearchriver_backlog is created, which contains a single document having meta-information about objects yet to be synced. It will be deleted once elasticsearch is reachable and sync is complete.primaryKeyField in mongodb document which will be used by the library._idstring.Elasticsearch v7.0
_type field depricated._collection_index_dictDependent packages
npm install mongodb
npm install elasticsearch
npm install mongo-river-elastic
npm install mongo-river-elastic --save
const River = require('mongo-river-elastic')
let river = new River(_mongo_db_ref, _es_ref, _collection_index_dict, options)
Parameters:
_mongo_db_ref -- Object
_es_ref -- Object
_collection_index_dict -- Object
_collection_index_dict =
{ 'collection1': {index: 'index1', type: 'type1', primaryKeyField: 'primaryKeyField1'},
'collection2': {index: 'index2', type: 'type2', primaryKeyField: 'primaryKeyField2'}}
where,
collection1: mongodb collection nameindex1: elasticsearch index nametype: elasticsearch index mapping name. Set to null if not applicable.primaryKeyField1: mongodb collection object key to be used as primary key in elasticsearchoptions -- Object
const elasticsearch = require('elasticsearch');
const MongoClient = require('mongodb').MongoClient;
const River = require('mongo-river-elastic');
// Connect Mongodb
MongoClient.connect('localhost:27017', function (err, mongoClient) {
const _mongo_db_ref = mongoClient.db('test_database');
// connect elasticsearch
const _es_ref = new elasticsearch.Client({host: 'localhost:9200'});
// init River
const ._collection_index_dict = {
'collection1': {index: 'index1', type: 'type1', primaryKeyField: '_id'},
'collection2': {index: 'index2', type: 'type2', primaryKeyField: 'uuid'}
};
const options= {logLevel: 'debug', retryCount: 3};
let river = new River(_mongo_db_ref, _es_ref, _collection_index_dict, options);
const mongodb_options = {}
//insert, insertOne, insertMany
river.insertOne('collection1', {'_id': '1', 'key': 'value'}, mongodb_options, (err, response) => {
...
});
river.insertMany('collection2', [
{'uuid': '1', 'key': 'value1'},
{'uuid': '2', 'key': 'value2'},
{'uuid': '3', 'key': 'value3'}], (err, response) => {
...
});
//update, updateOne, updateMany
river.updateOne('collection1', {'key': 'value'}, {$set: {'anotherKey': 'anotherValue'}}, mongodb_options, (err, response) => {
...
});
//deleteOne, deleteMany
river.deleteOne('collection1', {'key': 'value'},mongodb_options, (err, response) => {
...
});
river.replaceOne('collection1', {'key': 'value'}, {
'_id': 10,
'key': 'value',
'anotherKey': 'another value'
}, (err, response) => {
});
river.bulkWrite('collection1',
[
{insertOne: {document: {'_id': '1', 'key': 'value'}}},
{updateOne: {filter: {'key': 'value'},update: {$set: {'anotherKey': 'anotherValue'}},upsert: true}},
{deleteOne: {filter: {'key': 'value'}}},
],mongodb_options, (err, response) => {
});
This project is licensed under the MIT License
FAQs
mongodb to elastic river plugin, sync realtime
We found that mongo-river-elastic demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.