live-cache 0.2.6 → 0.2.7

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.
@@ -15,11 +15,13 @@ export default class Collection<TVariable, TName extends string> {
15
15
  private dataMap;
16
16
  private indexes;
17
17
  private counter;
18
+ lastUpdated: Date;
18
19
  constructor(name: TName);
19
20
  /**
20
21
  * Clear all in-memory documents and indexes.
21
22
  */
22
23
  clear(): void;
24
+ updateLastUpdated(): void;
23
25
  /**
24
26
  * Add a document to all relevant indexes
25
27
  */
package/dist/index.cjs CHANGED
@@ -133,6 +133,7 @@ class Collection {
133
133
  this.dataMap = {};
134
134
  this.indexes = {};
135
135
  this.counter = 0;
136
+ this.lastUpdated = new Date();
136
137
  }
137
138
  /**
138
139
  * Clear all in-memory documents and indexes.
@@ -141,6 +142,10 @@ class Collection {
141
142
  this.dataMap = {};
142
143
  this.indexes = {};
143
144
  this.counter = 0;
145
+ this.lastUpdated = new Date();
146
+ }
147
+ updateLastUpdated() {
148
+ this.lastUpdated = new Date();
144
149
  }
145
150
  /**
146
151
  * Add a document to all relevant indexes
@@ -168,6 +173,7 @@ class Collection {
168
173
  if (!this.indexes[fullIndexKey].includes(doc._id)) {
169
174
  this.indexes[fullIndexKey].push(doc._id);
170
175
  }
176
+ this.updateLastUpdated();
171
177
  }
172
178
  /**
173
179
  * Remove a document from all indexes
@@ -195,6 +201,7 @@ class Collection {
195
201
  delete this.indexes[fullIndexKey];
196
202
  }
197
203
  }
204
+ this.updateLastUpdated();
198
205
  }
199
206
  /**
200
207
  * Find a single document by _id or by matching conditions (optimized with indexes)
@@ -263,6 +270,7 @@ class Collection {
263
270
  this.dataMap[doc._id] = doc;
264
271
  // Add to indexes
265
272
  this.addToIndexes(doc);
273
+ this.updateLastUpdated();
266
274
  return doc;
267
275
  }
268
276
  /**
@@ -277,6 +285,7 @@ class Collection {
277
285
  this.removeFromIndexes(doc);
278
286
  // Remove from dataMap
279
287
  delete this.dataMap[doc._id];
288
+ this.updateLastUpdated();
280
289
  return true;
281
290
  }
282
291
  /**
@@ -301,6 +310,7 @@ class Collection {
301
310
  this.removeFromIndexes(doc);
302
311
  doc.updateData(update);
303
312
  this.addToIndexes(doc);
313
+ this.updateLastUpdated();
304
314
  return doc;
305
315
  }
306
316
  /**
@@ -317,6 +327,7 @@ class Collection {
317
327
  this.addToIndexes(doc);
318
328
  insertedDocs.push(doc);
319
329
  }
330
+ this.updateLastUpdated();
320
331
  return insertedDocs;
321
332
  }
322
333
  /**