Comparing version 5.2.2 to 6.0.0
@@ -51,2 +51,11 @@ "use strict"; | ||
async balance(query, options = {}) { | ||
if (options) { | ||
// If there is a session, we must NOT set any readPreference (as per mongo v5 and v6). | ||
// https://www.mongodb.com/docs/v6.0/core/transactions/#read-concern-write-concern-read-preference | ||
// Otherwise, we are free to use any readPreference. | ||
if (!options.session && !options.readPreference) { | ||
// Let's try reading from the secondary node, if available. | ||
options.readPreference = "secondaryPreferred"; | ||
} | ||
} | ||
const parsedQuery = (0, parseBalanceQuery_1.parseBalanceQuery)(query, this); | ||
@@ -53,0 +62,0 @@ const meta = parsedQuery.meta; |
@@ -74,4 +74,4 @@ "use strict"; | ||
const key = hashKey(constructKey(book, account, { ...meta, ...extras })); | ||
return exports.balanceModel.collection.findOne({ key }, { sort: { _id: -1 }, session: options.session }); | ||
return exports.balanceModel.collection.findOne({ key }, { sort: { _id: -1 }, ...options }); | ||
} | ||
exports.getBestSnapshot = getBestSnapshot; |
{ | ||
"name": "medici", | ||
"version": "5.2.2", | ||
"description": "Simple double-entry accounting for Node + Mongoose", | ||
"version": "6.0.0", | ||
"description": "Double-entry accounting ledger for Node + Mongoose", | ||
"main": "build/index.js", | ||
@@ -28,9 +28,7 @@ "types": "types/index.d.ts", | ||
"build/", | ||
"types/", | ||
"README.md", | ||
"LICENSE" | ||
"types/" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/flash-oss/medici" | ||
"url": "https://github.com/flash-oss/medici" | ||
}, | ||
@@ -43,3 +41,4 @@ "keywords": [ | ||
"mongodb", | ||
"mongoose" | ||
"mongoose", | ||
"ledger" | ||
], | ||
@@ -61,3 +60,3 @@ "author": { | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^16.11.12", | ||
"@types/node": "^18.6.4", | ||
"@types/sinon": "^10.0.6", | ||
@@ -73,5 +72,5 @@ "@typescript-eslint/eslint-plugin": "^5.7.0", | ||
"eslint-plugin-security-node": "^1.0.14", | ||
"eslint-plugin-sonarjs": "^0.11.0", | ||
"eslint-plugin-sonarjs": "^0.14.0", | ||
"luxon": "^3.0.1", | ||
"mocha": "^9.1.3", | ||
"mocha": "^10.2.0", | ||
"moment": "^2.29.1", | ||
@@ -83,4 +82,4 @@ "mongodb-memory-server": "^8.0.4", | ||
"sinon": "^14.0.0", | ||
"ts-mocha": "^9.0.2", | ||
"tsd": "^0.19.0", | ||
"ts-mocha": "^10.0.0", | ||
"tsd": "^0.22.0", | ||
"typescript": "^4.5.4" | ||
@@ -102,4 +101,4 @@ }, | ||
"engines": { | ||
"node": ">=12" | ||
"node": ">=16" | ||
} | ||
} |
@@ -1,3 +0,4 @@ | ||
// Generated by dts-bundle-generator v6.12.0 | ||
// Generated by dts-bundle-generator v6.13.0 | ||
import { ReadPreferenceLike } from 'mongodb'; | ||
import { ClientSession, Document, Schema, Types } from 'mongoose'; | ||
@@ -59,2 +60,3 @@ | ||
session?: ClientSession; | ||
readPreference?: ReadPreferenceLike; | ||
}; | ||
@@ -61,0 +63,0 @@ export declare class Entry<U extends ITransaction = ITransaction, J extends IJournal = IJournal> { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79377
1174