@mikro-orm/core 7.1.10-dev.9 → 7.1.11-dev.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.
@@ -67,7 +67,8 @@ export declare abstract class DatabaseDriver<C extends Connection> implements ID
67
67
  /**
68
68
  * Restores the JS value of a single cursor offset: ISO strings become `Date` instances based on the
69
69
  * property type (never based on the string shape alone), and custom types are restored via
70
- * `convertToJSValue`. Values compared against a JSON document keep their serialized form instead.
70
+ * `convertToJSValue`. Values compared against a JSON document keep their serialized form instead,
71
+ * unless the platform preserves native date types inside JSON documents (mongo).
71
72
  */
72
73
  private mapCursorOffset;
73
74
  protected createCursorCondition<T extends object>(definition: (readonly [keyof T & string, QueryOrder])[], offsets: Dictionary[], inverse: boolean, meta: EntityMetadata<T>): FilterQuery<T>;
@@ -205,7 +205,8 @@ export class DatabaseDriver {
205
205
  /**
206
206
  * Restores the JS value of a single cursor offset: ISO strings become `Date` instances based on the
207
207
  * property type (never based on the string shape alone), and custom types are restored via
208
- * `convertToJSValue`. Values compared against a JSON document keep their serialized form instead.
208
+ * `convertToJSValue`. Values compared against a JSON document keep their serialized form instead,
209
+ * unless the platform preserves native date types inside JSON documents (mongo).
209
210
  */
210
211
  mapCursorOffset(prop, value, insideJson) {
211
212
  if (Utils.isScalarReference(value)) {
@@ -218,7 +219,7 @@ export class DatabaseDriver {
218
219
  if (value == null) {
219
220
  return value;
220
221
  }
221
- if (insideJson) {
222
+ if (insideJson && !this.platform.preservesDatesInsideJson()) {
222
223
  // compared against the JSON document, which holds the serialized form
223
224
  if (value instanceof Date) {
224
225
  return value.toISOString();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.1.10-dev.9",
3
+ "version": "7.1.11-dev.0",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "keywords": [
6
6
  "data-mapper",
@@ -227,6 +227,8 @@ export declare abstract class Platform {
227
227
  formatIndexHint(indexNames: string[]): string | undefined;
228
228
  /** Whether the driver automatically parses JSON columns into JS objects. */
229
229
  convertsJsonAutomatically(): boolean;
230
+ /** Whether date values inside JSON documents keep their native type (e.g. BSON dates), instead of being serialized to ISO strings. */
231
+ preservesDatesInsideJson(): boolean;
230
232
  /** Converts a JS value to its JSON database representation (typically JSON.stringify). */
231
233
  convertJsonToDatabaseValue(value: unknown, context?: TransformContext): unknown;
232
234
  /** Converts a database JSON value to its JS representation. */
@@ -465,6 +465,10 @@ export class Platform {
465
465
  convertsJsonAutomatically() {
466
466
  return true;
467
467
  }
468
+ /** Whether date values inside JSON documents keep their native type (e.g. BSON dates), instead of being serialized to ISO strings. */
469
+ preservesDatesInsideJson() {
470
+ return false;
471
+ }
468
472
  /** Converts a JS value to its JSON database representation (typically JSON.stringify). */
469
473
  convertJsonToDatabaseValue(value, context) {
470
474
  return JSON.stringify(value);
package/utils/Utils.js CHANGED
@@ -153,7 +153,7 @@ export function parseJsonSafe(value) {
153
153
  /** Collection of general-purpose utility methods used throughout the ORM. */
154
154
  export class Utils {
155
155
  static PK_SEPARATOR = '~~~';
156
- static #ORM_VERSION = '7.1.10-dev.9';
156
+ static #ORM_VERSION = '7.1.11-dev.0';
157
157
  /**
158
158
  * Checks if the argument is instance of `Object`. Returns false for arrays.
159
159
  */