@omegup/msync 0.0.32 → 0.0.33

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 (3) hide show
  1. package/index.esm.js +13 -4
  2. package/index.js +13 -4
  3. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -1219,7 +1219,10 @@ const makeWatchStream = (db, { collection, projection: p, hardMatch: m }, startA
1219
1219
  };
1220
1220
 
1221
1221
  const actions = {
1222
- updateMany: (c, args) => [c.updateMany(...args), [`db['${c.collectionName}'].updateMany(...`, args, ')']],
1222
+ updateMany: (c, args) => [
1223
+ c.updateMany(...args),
1224
+ [`db['${c.collectionName}'].updateMany(...`, args, ')'],
1225
+ ],
1223
1226
  };
1224
1227
  const streamNames = {};
1225
1228
  const executes$1 = (view, input, streamName) => {
@@ -1287,7 +1290,11 @@ const executes$1 = (view, input, streamName) => {
1287
1290
  const step2 = () => Promise.all([
1288
1291
  last.findOne({ _id: streamName, data }),
1289
1292
  last.findOne({ _id: streamName }),
1290
- ]).then(ts => next(step2_5(ts), ts[0] ? `no teardown to handle, starting at ${ts[0].ts}` : ts[1] ? 'handle teardown' : 'start fresh'));
1293
+ ]).then(ts => next(step2_5(ts), ts[0]
1294
+ ? `no teardown to handle, starting at ${ts[0].ts}`
1295
+ : ts[1]
1296
+ ? 'handle teardown'
1297
+ : 'start fresh'));
1291
1298
  const step2_5 = ([same, exists]) => async () => {
1292
1299
  const handleTeardown = async (last) => {
1293
1300
  if (!last.data)
@@ -1308,11 +1315,13 @@ const executes$1 = (view, input, streamName) => {
1308
1315
  return next(step3(same), 'clone into new collection');
1309
1316
  };
1310
1317
  const step3 = (lastTS) => async () => {
1311
- const hardQuery = $and(lastTS && root().of('touchedAt').has($gteTs(lastTS.ts)), hardMatch);
1318
+ const hardQuery = $and(lastTS
1319
+ ? root().of('touchedAt').has($gteTs(lastTS.ts))
1320
+ : root().of('deletedAt').has($eq(null)), lastTS ? null : match && $expr(match), hardMatch);
1312
1321
  const notDeleted = eq($ifNull(root().of('deletedAt').expr(), nil))(nil);
1313
1322
  const query = match ? and(notDeleted, match) : notDeleted;
1314
1323
  const replaceRaw = $replaceWith_(field({
1315
- after: ['after', ite(query, root().expr(), nil)],
1324
+ after: ['after', lastTS ? ite(query, root().expr(), nil) : root().expr()],
1316
1325
  updated: ['updated', val(true)],
1317
1326
  _id: ['_id', root().of('_id').expr()],
1318
1327
  }));
package/index.js CHANGED
@@ -1221,7 +1221,10 @@ const makeWatchStream = (db, { collection, projection: p, hardMatch: m }, startA
1221
1221
  };
1222
1222
 
1223
1223
  const actions = {
1224
- updateMany: (c, args) => [c.updateMany(...args), [`db['${c.collectionName}'].updateMany(...`, args, ')']],
1224
+ updateMany: (c, args) => [
1225
+ c.updateMany(...args),
1226
+ [`db['${c.collectionName}'].updateMany(...`, args, ')'],
1227
+ ],
1225
1228
  };
1226
1229
  const streamNames = {};
1227
1230
  const executes$1 = (view, input, streamName) => {
@@ -1289,7 +1292,11 @@ const executes$1 = (view, input, streamName) => {
1289
1292
  const step2 = () => Promise.all([
1290
1293
  last.findOne({ _id: streamName, data }),
1291
1294
  last.findOne({ _id: streamName }),
1292
- ]).then(ts => next(step2_5(ts), ts[0] ? `no teardown to handle, starting at ${ts[0].ts}` : ts[1] ? 'handle teardown' : 'start fresh'));
1295
+ ]).then(ts => next(step2_5(ts), ts[0]
1296
+ ? `no teardown to handle, starting at ${ts[0].ts}`
1297
+ : ts[1]
1298
+ ? 'handle teardown'
1299
+ : 'start fresh'));
1293
1300
  const step2_5 = ([same, exists]) => async () => {
1294
1301
  const handleTeardown = async (last) => {
1295
1302
  if (!last.data)
@@ -1310,11 +1317,13 @@ const executes$1 = (view, input, streamName) => {
1310
1317
  return next(step3(same), 'clone into new collection');
1311
1318
  };
1312
1319
  const step3 = (lastTS) => async () => {
1313
- const hardQuery = $and(lastTS && root().of('touchedAt').has($gteTs(lastTS.ts)), hardMatch);
1320
+ const hardQuery = $and(lastTS
1321
+ ? root().of('touchedAt').has($gteTs(lastTS.ts))
1322
+ : root().of('deletedAt').has($eq(null)), lastTS ? null : match && $expr(match), hardMatch);
1314
1323
  const notDeleted = eq($ifNull(root().of('deletedAt').expr(), nil))(nil);
1315
1324
  const query = match ? and(notDeleted, match) : notDeleted;
1316
1325
  const replaceRaw = $replaceWith_(field({
1317
- after: ['after', ite(query, root().expr(), nil)],
1326
+ after: ['after', lastTS ? ite(query, root().expr(), nil) : root().expr()],
1318
1327
  updated: ['updated', val(true)],
1319
1328
  _id: ['_id', root().of('_id').expr()],
1320
1329
  }));
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "module": "index.esm.js",
4
4
  "typings": "index.d.ts",
5
5
  "name": "@omegup/msync",
6
- "version": "0.0.32",
6
+ "version": "0.0.33",
7
7
  "dependencies": {
8
8
  "dayjs": "^1.11.9",
9
9
  "dotenv": "^16.3.1",