@mikro-orm/core 6.2.10-dev.82 → 6.2.10-dev.84

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.
@@ -1,4 +1,5 @@
1
1
  import type { NamingStrategy } from './NamingStrategy';
2
+ import { type ReferenceKind } from '../enums';
2
3
  export declare abstract class AbstractNamingStrategy implements NamingStrategy {
3
4
  getClassName(file: string, separator?: string): string;
4
5
  classToMigrationName(timestamp: string, customMigrationName?: string): string;
@@ -17,6 +18,10 @@ export declare abstract class AbstractNamingStrategy implements NamingStrategy {
17
18
  */
18
19
  enumValueToEnumProperty(enumValue: string, columnName: string, tableName: string, schemaName?: string): string;
19
20
  aliasName(entityName: string, index: number): string;
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ inverseSideName(entityName: string, propertyName: string, kind: ReferenceKind): string;
20
25
  abstract classToTableName(entityName: string): string;
21
26
  abstract joinColumnName(propertyName: string): string;
22
27
  abstract joinKeyColumnName(entityName: string, referencedColumnName?: string): string;
@@ -63,5 +63,18 @@ class AbstractNamingStrategy {
63
63
  // Take only the first letter of the prefix to keep character counts down since some engines have character limits
64
64
  return entityName.charAt(0).toLowerCase() + index;
65
65
  }
66
+ /**
67
+ * @inheritDoc
68
+ */
69
+ inverseSideName(entityName, propertyName, kind) {
70
+ if (kind === 'm:n') {
71
+ return propertyName + 'Inverse';
72
+ }
73
+ const suffix = kind === '1:m' && !entityName.endsWith('Collection') ? 'Collection' : '';
74
+ if (entityName.length === 1) {
75
+ return entityName[0].toLowerCase() + suffix;
76
+ }
77
+ return entityName[0].toLowerCase() + entityName.substring(1) + suffix;
78
+ }
66
79
  }
67
80
  exports.AbstractNamingStrategy = AbstractNamingStrategy;
@@ -1,3 +1,4 @@
1
+ import type { ReferenceKind } from '../enums';
1
2
  export interface NamingStrategy {
2
3
  /**
3
4
  * Return a name of the class based on its file name
@@ -62,7 +63,7 @@ export interface NamingStrategy {
62
63
  */
63
64
  joinKeyColumnName(entityName: string, referencedColumnName?: string, composite?: boolean): string;
64
65
  /**
65
- * Returns key/constraint name for given type. Some drivers might not support all the types (e.g. mysql and sqlite enforce the PK name).
66
+ * Returns key/constraint name for the given type. Some drivers might not support all the types (e.g. mysql and sqlite enforce the PK name).
66
67
  */
67
68
  indexName(tableName: string, columns: string[], type: 'primary' | 'foreign' | 'unique' | 'index' | 'sequence' | 'check'): string;
68
69
  /**
@@ -70,4 +71,8 @@ export interface NamingStrategy {
70
71
  * ensured via appended index parameter. It is optional to use it as long as you ensure it will be unique.
71
72
  */
72
73
  aliasName(entityName: string, index: number): string;
74
+ /**
75
+ * Returns the name of the inverse side property. Used in the `EntityGenerator` with `bidirectionalRelations` option.
76
+ */
77
+ inverseSideName(entityName: string, propertyName: string, kind: ReferenceKind): string;
73
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.2.10-dev.82",
3
+ "version": "6.2.10-dev.84",
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
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -64,7 +64,7 @@
64
64
  "esprima": "4.0.1",
65
65
  "fs-extra": "11.2.0",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.2.10-dev.82",
67
+ "mikro-orm": "6.2.10-dev.84",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }