@frogfish/k2db 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/db.js +8 -1
- package/package.json +1 -1
package/db.js
CHANGED
|
@@ -76,7 +76,10 @@ class K2DB {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
async get(collectionName, uuid) {
|
|
79
|
-
const res = await this.findOne(collectionName, {
|
|
79
|
+
const res = await this.findOne(collectionName, {
|
|
80
|
+
_uuid: uuid,
|
|
81
|
+
_deleted: { $ne: true },
|
|
82
|
+
});
|
|
80
83
|
if (!res) {
|
|
81
84
|
throw new k2error_1.K2Error(k2error_1.ServiceError.SYSTEM_ERROR, "Error getting the document with provided identity", "sys_mdb_get");
|
|
82
85
|
}
|
|
@@ -92,6 +95,8 @@ class K2DB {
|
|
|
92
95
|
async findOne(collectionName, criteria, fields) {
|
|
93
96
|
const collection = await this.getCollection(collectionName);
|
|
94
97
|
const projection = {};
|
|
98
|
+
// Ensure to include the _deleted filter in criteria
|
|
99
|
+
criteria._deleted = { $ne: true };
|
|
95
100
|
if (fields && fields.length > 0) {
|
|
96
101
|
fields.forEach((field) => {
|
|
97
102
|
projection[field] = 1;
|
|
@@ -438,6 +443,8 @@ class K2DB {
|
|
|
438
443
|
async count(collectionName, criteria) {
|
|
439
444
|
const collection = await this.getCollection(collectionName);
|
|
440
445
|
try {
|
|
446
|
+
// Ensure to include the _deleted filter in criteria
|
|
447
|
+
criteria._deleted = { $ne: true };
|
|
441
448
|
const cnt = await collection.countDocuments(criteria);
|
|
442
449
|
return { count: cnt };
|
|
443
450
|
}
|