@cocreate/mongodb
Advanced tools
Comparing version 1.17.1 to 1.17.2
@@ -0,1 +1,10 @@ | ||
## [1.17.2](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.17.1...v1.17.2) (2024-01-30) | ||
### Bug Fixes | ||
* error message ([0344407](https://github.com/CoCreate-app/CoCreate-mongodb/commit/03444076bbc9da8379d8d9a112170ff1c2d416f3)) | ||
* query.organization_id ([1bcbff7](https://github.com/CoCreate-app/CoCreate-mongodb/commit/1bcbff7c57df52aa984b16e1df800d9b3cb0a581)) | ||
* queryData ([e49ab52](https://github.com/CoCreate-app/CoCreate-mongodb/commit/e49ab526bfcd9897f7fb30f578cb142c9c5b0efd)) | ||
## [1.17.1](https://github.com/CoCreate-app/CoCreate-mongodb/compare/v1.17.0...v1.17.1) (2024-01-18) | ||
@@ -2,0 +11,0 @@ |
{ | ||
"name": "@cocreate/mongodb", | ||
"version": "1.17.1", | ||
"version": "1.17.2", | ||
"description": "A simple mongodb component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
const { MongoClient, ObjectId } = require('mongodb'); | ||
const { dotNotationToObject, query, searchData, sortData, isValidDate } = require('@cocreate/utils') | ||
const { dotNotationToObject, queryData, searchData, sortData, isValidDate } = require('@cocreate/utils') | ||
const clients = new Map() | ||
@@ -408,2 +408,6 @@ const organizations = {} | ||
try { | ||
// TODO: index is 1 if indexeddb already returned an item interfering with query | ||
// if (data.array === "keys") | ||
// index = 0 | ||
if (method === 'read') | ||
@@ -436,3 +440,3 @@ projection = { ...projections, ...projection } | ||
if (object.$storage && object.modified && object.modified.on) { | ||
if (document && new Date(object.modified.on) > new Date(document.modified.on)) { | ||
if (document && document.modified && new Date(object.modified.on) > new Date(document.modified.on)) { | ||
object = { ...document, ...object } | ||
@@ -656,3 +660,3 @@ createUpdate(update, options, object) | ||
if (data['organization_id']) | ||
query['organization_id'] = { $eq: data['organization_id'] } | ||
query['organization_id'] = data['organization_id'] | ||
@@ -744,17 +748,21 @@ return { query, sort, index, limit, count } | ||
function errorHandler(data, error, database, array) { | ||
if (typeof error == 'object') | ||
error['storage'] = 'mongodb' | ||
else | ||
error = { storage: data.storageName, message: error } | ||
let errorMessage = typeof error === 'object' && error.message ? error.message : error; | ||
let errorObject = { | ||
message: errorMessage, | ||
storage: 'mongodb' | ||
}; | ||
if (database) | ||
error['database'] = database | ||
errorObject.database = database; | ||
if (array) | ||
error['array'] = array | ||
if (data.error) | ||
data.error.push(error) | ||
else | ||
data.error = [error] | ||
errorObject.array = array; | ||
if (Array.isArray(data.error)) { | ||
data.error.push(errorObject); | ||
} else { | ||
data.error = [errorObject]; | ||
} | ||
} | ||
module.exports = { send } |
126566
677