@cocreate/elements 1.27.0 → 1.27.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.27.1](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.27.0...v1.27.1) (2023-11-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * condistions for matching elements and updating ([d7e7a39](https://github.com/CoCreate-app/CoCreate-elements/commit/d7e7a3920f9ccb1693b17f177a2734e3926a7e35))
7
+
1
8
  # [1.27.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.26.4...v1.27.0) (2023-11-19)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/elements",
3
- "version": "1.27.0",
3
+ "version": "1.27.1",
4
4
  "description": "Fetch content into any html element by using html5 attributes to query data stored in CoCreate headless CMS. If data is changed it will instantly reflect in html tags as changes are broadcasted in realtime",
5
5
  "keywords": [
6
6
  "elements",
package/src/index.js CHANGED
@@ -324,7 +324,8 @@ async function filterData(element, data, type, key) {
324
324
  Data.push(...doc[key])
325
325
  else
326
326
  Data.push(doc[key])
327
- }
327
+ } else
328
+ return
328
329
  }
329
330
  // if (Data.length === 1) {
330
331
  // data = { [key]: Data[0] }
@@ -486,6 +487,7 @@ function getDataElements(data) {
486
487
  return element
487
488
  }
488
489
 
490
+ // TODO: Correctly check for matches
489
491
  function getDataKeys(data) {
490
492
  const matchingKeyStrings = [];
491
493
  const targetKeys = ["type", "storage", "database", "array", "index", "object", '$filter'];
@@ -494,7 +496,7 @@ function getDataKeys(data) {
494
496
  let hasMatch = true;
495
497
 
496
498
  for (const key of targetKeys) {
497
- if (!data.$filter && (data.type === key || key === '$filter'))
499
+ if (!data.$filter && key === '$filter' && sortedKey.data.hasOwnProperty(key))
498
500
  hasMatch = true
499
501
  else if (data.hasOwnProperty(key)) {
500
502
  if (!sortedKey.data.hasOwnProperty(key)) {
@@ -505,7 +507,14 @@ function getDataKeys(data) {
505
507
  // if key is object check _id
506
508
  const matches = sortedKey.data[key].some(value => {
507
509
  if (key === 'object') {
508
- return data[key].some(obj => obj._id === value._id);
510
+ return data[key].some(obj => {
511
+ if (data.array.includes('users'))
512
+ console.log('users')
513
+ if (data.array.includes('questions'))
514
+ console.log('questions')
515
+
516
+ return obj._id === value._id
517
+ });
509
518
  } else {
510
519
  return data[key].includes(value)
511
520
  }