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

viewmodel

Package Overview
Dependencies
Maintainers
2
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

viewmodel - npm Package Compare versions

Comparing version 1.10.11 to 1.11.0

33

lib/repository.js

@@ -127,3 +127,7 @@ var tolerate = require('tolerance'),

vm.set('commitStamp', (new Date()).getTime());
orgCommit.apply(this, [vm, callback]);
repo.emit('before-database-commit', Date.now(), vm);
orgCommit.apply(this, [vm, function (err, res) {
repo.emit('after-database-commit', Date.now(), vm);
if (callback) callback(err, res);
}]);
};

@@ -141,3 +145,5 @@ var orgFind = repo.find;

}
repo.emit('before-database-find', Date.now(), query, queryOptions);
orgFind.apply(this, [query, queryOptions, function (err, res) {
repo.emit('after-database-find', Date.now(), query, queryOptions);
if (err) {

@@ -170,4 +176,21 @@ return callback(err);

}
orgFindOne.apply(this, [query, queryOptions, callback]);
repo.emit('before-database-findOne', Date.now(), query, queryOptions);
orgFindOne.apply(this, [query, queryOptions, function (err, res) {
repo.emit('after-database-findOne', Date.now(), query, queryOptions);
if (callback) callback(err, res);
}]);
};
var orgGet = repo.get;
repo.get = function (id, callback) {
if (typeof id === 'function') {
callback = id;
id = null;
}
repo.emit('before-database-get', Date.now(), id);
orgGet.apply(this, [id, function (err, res) {
repo.emit('after-database-get', Date.now(), id);
if (callback) callback(err, res);
}]);
};
// Do not modify anything... it's write and we can do everything!!!

@@ -206,3 +229,5 @@ connect(repo, options, callback);

}
repo.emit('before-database-get', Date.now(), id);
orgGet.apply(this, [id, function (err, res) {
repo.emit('after-database-get', Date.now(), id);
if (err) {

@@ -232,3 +257,5 @@ return callback(err);

}
repo.emit('before-database-find', Date.now(), query, queryOptions);
orgFind.apply(this, [query, queryOptions, function (err, res) {
repo.emit('after-database-find', Date.now(), query, queryOptions);
if (err) {

@@ -265,3 +292,5 @@ return callback(err);

}
repo.emit('before-database-findOne', Date.now(), query, queryOptions);
orgFindOne.apply(this, [query, queryOptions, function (err, res) {
repo.emit('after-database-findOne', Date.now(), query, queryOptions);
if (err) {

@@ -268,0 +297,0 @@ return callback(err);

6

package.json
{
"author": "adrai",
"name": "viewmodel",
"version": "1.10.11",
"version": "1.11.0",
"private": false,

@@ -17,7 +17,7 @@ "main": "index.js",

"jsondate": "0.0.1",
"lodash": "4.17.10",
"lodash": "4.17.11",
"parent-require": "1.0.0",
"sift": "5.0.0",
"tolerance": "1.0.0",
"uuid": "3.1.0"
"uuid": "3.3.2"
},

@@ -24,0 +24,0 @@ "devDependencies": {

@@ -194,3 +194,15 @@ # Introduction

## Catch before and after database events
var repository = viewmodel.write({ type: 'mongodb' });
repository.on('before-database-get', function(ms, id) { console.log(ms, id); });
repository.on('after-database-get', function(ms, id) { console.log(ms, id); });
repository.on('before-database-find', function(ms, query, queryOptions) { console.log(ms, query, queryOptions); });
repository.on('after-database-find', function(ms, query, queryOptions) { console.log(ms, query, queryOptions); });
repository.on('before-database-findOne', function(ms, query, queryOptions) { console.log(ms, query, queryOptions); });
repository.on('after-database-findOne', function(ms, query, queryOptions) { console.log(ms, query, queryOptions); });
repository.on('before-database-commit', function(ms, vm) { console.log(ms, vm); });
repository.on('after-database-commit', function(ms, vm) { console.log(ms, vm); });
# Implementation differences

@@ -339,3 +351,3 @@

Copyright (c) 2018 Adriano Raiano
Copyright (c) 2019 Adriano Raiano

@@ -342,0 +354,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

@@ -0,1 +1,4 @@

## [v1.11.0](https://github.com/adrai/node-viewmodel/compare/v1.10.11...v1.11.0)
- introduce before and after database events
## [v1.10.11](https://github.com/adrai/node-viewmodel/compare/v1.10.10...v1.10.11)

@@ -2,0 +5,0 @@ - Fix options indexes [#68](https://github.com/adrai/node-viewmodel/pull/68) thanks to [tommiii](https://github.com/tommiii)

Sorry, the diff of this file is not supported yet

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