@dnax/core 0.14.9 → 0.15.0

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.
Files changed (2) hide show
  1. package/lib/collection.ts +9 -19
  2. package/package.json +1 -1
package/lib/collection.ts CHANGED
@@ -92,7 +92,6 @@ async function syncCollectionDatabase() {
92
92
  }
93
93
 
94
94
  // suppression auto Removes des indexes
95
-
96
95
  if (c?.autoRemoveIndexes?.length && c?.autoRemoveIndexes) {
97
96
  for await (let index of c?.autoRemoveIndexes || []) {
98
97
  await t.database?.db
@@ -112,33 +111,24 @@ async function syncCollectionDatabase() {
112
111
  // console.log('Allindex',allIndexes)
113
112
 
114
113
  for await (let dbIndex of allIndexes || []) {
115
- if (
116
- dbIndex?.key?.createdAt ||
117
- dbIndex?.key?.updatedAt ||
118
- dbIndex?.key?._id
119
- ) {
120
- continue;
114
+ // creation des indexes createdAt / updatedAt
115
+ if (!dbIndex?.key?.createdAt && !dbIndex?.key?.updatedAt) {
116
+ await t.database.db
117
+ ?.collection(c.slug)
118
+ .createIndex(["createdAt", "updatedAt"])
119
+ .then((e) => {})
120
+ .catch((err) => {});
121
121
  }
122
122
  }
123
123
 
124
- //console.log(t.database.db);
125
- // 1- Creation des indexes normal
126
- await t.database.db
127
- ?.collection(c.slug)
128
- .createIndex(["createdAt", "updatedAt"])
129
- .then((e) => {})
130
- .catch((err) => {
131
- console.error(err?.message);
132
- });
133
-
134
124
  // 2- Creation des indexes par champs unique/random
135
-
136
125
  c.fields?.map((f) => {
137
126
  if (f?.index) {
138
127
  t.database.db?.collection(c.slug).createIndex({
139
128
  [f.name]: f.index == true ? 1 : f.index,
140
129
  });
141
130
  }
131
+
142
132
  if (f?.unique || f?.random) {
143
133
  t.database.db
144
134
  ?.collection(c.slug)
@@ -152,7 +142,7 @@ async function syncCollectionDatabase() {
152
142
  }
153
143
  )
154
144
  .catch((err) => {
155
- console.error(err);
145
+ //console.error(err);
156
146
  });
157
147
  }
158
148
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.14.9",
3
+ "version": "0.15.0",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {