rads-db 3.1.2 → 3.1.5

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/dist/index.cjs CHANGED
@@ -352,12 +352,16 @@ const computedPresets = {
352
352
  throw new Error('To use "createdBy" preset, please, provide "context.getUser" to "createRads" call.');
353
353
  return ___default.pick(ctx.getUser(), "id");
354
354
  },
355
- updatedBy: ({ doc, ctx }) => {
355
+ updatedBy: ({ doc, oldDoc, fieldName, ctx }) => {
356
+ if (ctx.isVerifying && oldDoc?.updatedBy)
357
+ return oldDoc.updatedBy;
356
358
  if (!ctx.getUser)
357
359
  throw new Error('To use "updatedBy" preset, please, provide "context.getUser" to "createRads" call.');
358
360
  return ___default.pick(ctx.getUser(), "id");
359
361
  },
360
- updatedAt: ({ doc, oldDoc }) => {
362
+ updatedAt: ({ doc, oldDoc, ctx }) => {
363
+ if (ctx.isVerifying && oldDoc.updatedAt)
364
+ return oldDoc.updatedAt;
361
365
  return (/* @__PURE__ */ new Date()).toISOString();
362
366
  },
363
367
  autoincrement: () => {
@@ -819,7 +823,7 @@ function getRadsDbMethods(key, computedContext, driverInstance) {
819
823
  if (driverInstance.verifyMany) {
820
824
  return driverInstance.verifyMany(args, ctx);
821
825
  }
822
- ctx = { ...options.context, ...ctx };
826
+ ctx = { ...options.context, ...ctx, isVerifying: true };
823
827
  if (args?.dryRun) {
824
828
  ctx._logs = ctx._logs || [];
825
829
  ctx.dryRun = true;
package/dist/index.mjs CHANGED
@@ -345,12 +345,16 @@ const computedPresets = {
345
345
  throw new Error('To use "createdBy" preset, please, provide "context.getUser" to "createRads" call.');
346
346
  return _.pick(ctx.getUser(), "id");
347
347
  },
348
- updatedBy: ({ doc, ctx }) => {
348
+ updatedBy: ({ doc, oldDoc, fieldName, ctx }) => {
349
+ if (ctx.isVerifying && oldDoc?.updatedBy)
350
+ return oldDoc.updatedBy;
349
351
  if (!ctx.getUser)
350
352
  throw new Error('To use "updatedBy" preset, please, provide "context.getUser" to "createRads" call.');
351
353
  return _.pick(ctx.getUser(), "id");
352
354
  },
353
- updatedAt: ({ doc, oldDoc }) => {
355
+ updatedAt: ({ doc, oldDoc, ctx }) => {
356
+ if (ctx.isVerifying && oldDoc.updatedAt)
357
+ return oldDoc.updatedAt;
354
358
  return (/* @__PURE__ */ new Date()).toISOString();
355
359
  },
356
360
  autoincrement: () => {
@@ -812,7 +816,7 @@ function getRadsDbMethods(key, computedContext, driverInstance) {
812
816
  if (driverInstance.verifyMany) {
813
817
  return driverInstance.verifyMany(args, ctx);
814
818
  }
815
- ctx = { ...options.context, ...ctx };
819
+ ctx = { ...options.context, ...ctx, isVerifying: true };
816
820
  if (args?.dryRun) {
817
821
  ctx._logs = ctx._logs || [];
818
822
  ctx.dryRun = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rads-db",
3
- "version": "3.1.2",
3
+ "version": "3.1.5",
4
4
  "packageManager": "pnpm@8.6.1",
5
5
  "description": "Say goodbye to boilerplate code and hello to efficient and elegant syntax.",
6
6
  "author": "",