Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
reactive-mongodb
Advanced tools
An ODM for MongoDB with very strict data types/stucture. It is Based on Observable (with RxJS)
Reactive-MongoDB is An ODM for MongoDB with very strict data types/stucture. It is Based on Observable (with RxJS).
You can read about all the benefits of the Reactive approach (Reactive Architectures) here : RxJS5
Use RxJS's Operators you can work easily on your mongodb documents and define complexe behaviors in an easy to reason about way.
Currently working on data models so you can specifie the structure of your JSON objects and validate them before inserting them into your database. I made a module hyvalidator specificly for data validation, I plan on using it for this module to validate the data models.
Always Open For Suggestions. you can leave them as Issues
Please report your bugs here: Issues
Add the project to your dependencies
npm install --save reactive-mongodb
To properly setup you need to connect to your mongo database with the following commands:
const connect = require('reactive-mongodb').connect;
connect('YOUR_DATABASE_URL');
You only need to do this once.
Reactive-MongoDB allows you to interact with your collections after you connect to your database.
const Collection = require('../index.js').Collection;
//Collection is a class that represents your collection in the database
const Users = new Collection('users');
// 'users' will be the name of the collection in the mongodb database
const Collection = require('reactive-mongodb').Collection;
const Users = new Collection('users');
var user; //A document you want to insert
function onItemReceived(item) {
// item is the document you inserted into the database
// Your Own Logic
}
function errorHandler(err) {
// err is the error thrown by the method
// Your Own Logic
}
function completionHandler() {
// Your Own Logic
}
Users.insert(user).subscribe(onItemReceived, errorHandler, completionHandler);
const Collection = require('reactive-mongodb').Collection;
const Users = new Collection('users');
var oldUser; //A document you want to update
var newUser; //A document you want to update
function errorHandler(err) {
// err is the error thrown by the method
// Your Own Logic
}
function completionHandler() {
// Your Own Logic
}
Users.updateOne(oldUser,newUser).subscribe(null, errorHandler, completionHandler);
Update will replace the oldUser by the newOne. If you want to update specifique field you have to use {$set:{fields:values}} instead of newUser:
Users.updateOne(oldUser,{$set:{fields:values}}).subscribe(null, errorHandler, completionHandler);
const Collection = require('reactive-mongodb').Collection;
const Users = new Collection('users');
var newUser; // The New Document
function errorHandler(err) {
// err is the error thrown by the method
// Your Own Logic
}
function completionHandler() {
// Your Own Logic
}
Users.updateById(id,newUser).subscribe(null, errorHandler, completionHandler);
// You can also use $set instead of new User, See note Above
const Collection = require('reactive-mongodb').Collection;
const Users = new Collection('users');
var query; //A query to determine which documents to update
function errorHandler(err) {
// err is the error thrown by the method
// Your Own Logic
}
function completionHandler() {
// Your Own Logic
}
Users.update(query,{$set:{fields:values}}).subscribe(null, errorHandler, completionHandler);
// You have to specifie which fields to update with $set
const Collection = require('reactive-mongodb').Collection;
const Users = new Collection('users');
var query; //A query to determine which documents to delete
function errorHandler(err) {
// err is the error thrown by the method
// Your Own Logic
}
function completionHandler() {
// Your Own Logic
}
Users.delete(query).subscribe(null, errorHandler, completionHandler);
const Collection = require('reactive-mongodb').Collection;
const Users = new Collection('users');
function errorHandler(err) {
// err is the error thrown by the method
// Your Own Logic
}
function completionHandler() {
// Your Own Logic
}
Users.deleteById(id).subscribe(null, errorHandler, completionHandler);
The Id is the MongoDB ObjectID, you just need to pass in the String value Example :
Users.deleteById("590db2cc375bcc2cddc450a5").subscribe(onItemReceived, errorHandler, completionHandler);
const Collection = require('reactive-mongodb').Collection;
const Users = new Collection('users');
const query = {
//Some Values
};
function onItemReceived(item) {
// item is one of element of the array of documents that match the query
// Your Own Logic
}
function errorHandler(err) {
// err is the error thrown by the method
// Your Own Logic
}
function completionHandler() {
// Your Own Logic
}
Users.find(query).subscribe(onItemReceived, errorHandler, completionHandler);
// find will always return an array
const Collection = require('reactive-mongodb').Collection;
const Users = new Collection('users');
const query = {
//Some Values
};
function onItemReceived(item) {
// item is one of element of the array of documents that match the query
}
function errorHandler(err) {
// err is the error thrown by the method
// Your Own Logic
}
function completionHandler() {
// Your Own Logic
}
Users.findOne(query).subscribe(onItemReceived, errorHandler, completionHandler);
// find will return the first document Encoutered
const Collection = require('reactive-mongodb').Collection;
const Users = new Collection('users');
function onItemReceived(item) {
// item is one of element of the array of documents that match the query
// Your Own Logic
}
function errorHandler(err) {
// err is the error thrown by the method
// Your Own Logic
}
function completionHandler() {
// Your Own Logic
}
Users.findById(id).subscribe(onItemReceived, errorHandler, completionHandler);
// Id is the string value of Object ID Of MongoDB, see delete by Id Example.
I'm Khaled Romdhane but mostly known as heiyuki. My handle is : @heiyukidev.
I Work at this amazing Company @redcarpetsolutions don't hesitate to go check us out.
This project is backed By redcarpetsolutions
FAQs
An ODM for MongoDB with very strict data types/stucture. It is Based on Observable (with RxJS)
The npm package reactive-mongodb receives a total of 1 weekly downloads. As such, reactive-mongodb popularity was classified as not popular.
We found that reactive-mongodb 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.