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

transactions-mongoose

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

transactions-mongoose - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

22

examples/create-insert.js

@@ -14,2 +14,4 @@ /*

const {Transaction} = require("../src/index");
const {describe, it} = require("node:test");
const {strict: assert} = require("node:assert");

@@ -52,4 +54,24 @@ (async () => {

// test _id <--> idSynonym
const doc = transactionData1.result._doc; // extract result
doc.id = doc._id; // copy orig _id to id
delete doc._id;
const td = transaction.add(Person, doc);
await transaction.commit();
console.log('persons', await Person.find())
// check
const count = await Person.countDocuments({})
const count2 = await Person.countDocuments({firstname: 'Sancho'})
describe('Transactions - No Replica Set', () => {
it('Persons count 4', () => {
assert.strictEqual(count, 4);
})
it('Sancho count 2', () => {
assert.strictEqual(count2, 2);
})
})
await mongoose.disconnect();
await mongod.stop();
})();

@@ -15,2 +15,4 @@ /*

const personHelper = require('./personHelper');
const {describe, it} = require("node:test");
const {strict: assert} = require("node:assert");

@@ -67,5 +69,21 @@ (async () => {

// check
personSancho = await Person.findById(persons.Sancho._id); // test Sancho exists?
personJanna = await Person.findById(persons.Janna._id);
personHulio = await Person.findById(persons.Hulio._id);
describe('Transactions - No Replica Set', () => {
it('Sancho married', () => {
assert.strictEqual(personSancho.status, 'married');
})
it('Janna married', () => {
assert.strictEqual(personJanna.status, 'married');
})
it('Sancho friend Janna', () => {
assert.strictEqual(personJanna._id.toString(), personSancho.friend_id.toString());
})
})
await mongoose.disconnect();
await mongod.stop();
})();

4

package.json
{
"name": "transactions-mongoose",
"version": "1.2.1",
"version": "1.2.2",
"description": "Transactions for mongoose",

@@ -8,3 +8,3 @@ "main": "index.js",

"type": "git",
"url": "https://github.com/rosbitskyy/transactions-mongoose.git"
"url": "git+https://github.com/rosbitskyy/transactions-mongoose.git"
},

@@ -11,0 +11,0 @@ "keywords": [

@@ -186,3 +186,11 @@ /*

isValidArguments(model, object) {
return (!this.isModel(model) && this.isExecutor(object)) || (this.isModel(model) && (this.isDocument(object) || this.isCleanDocument(object)))
if (object) delete object.id
const isExecutor = (!this.isModel(model) && this.isExecutor(object));
const isDoc = (this.isModel(model) && (this.isDocument(object) || this.isCleanDocument(object)));
const exclude = ['__v', '_id', 'id'];
if (isDoc) {
if (this.isCleanDocument(object) && !object._id) exclude.map(it => delete object[it]);
else if (this.isDocument(object) && !object._doc._id) exclude.map(it => delete object._doc[it]);
}
return isExecutor || isDoc;
}

@@ -189,0 +197,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