MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / from

Method from

packages/sql/src/query/NativeQueryBuilder.ts:97–114  ·  view source on GitHub ↗
(tableName: string | RawQueryFragment | NativeQueryBuilder, options?: TableOptions)

Source from the content-addressed store, hash-verified

95 }
96
97 from(tableName: string | RawQueryFragment | NativeQueryBuilder, options?: TableOptions): this {
98 if (tableName instanceof NativeQueryBuilder) {
99 tableName = tableName.toRaw();
100 }
101
102 if (typeof tableName === 'string') {
103 const asKeyword = this.platform.usesAsKeyword() ? ' as ' : ' ';
104 const alias = options?.alias ? `${asKeyword}${this.platform.quoteIdentifier(options.alias)}` : '';
105 const schema =
106 options?.schema && options.schema !== this.platform.getDefaultSchemaName() ? `${options.schema}.` : '';
107 tableName = this.quote(schema + tableName) + alias;
108 }
109
110 this.options.tableName = tableName;
111 this.options.indexHint = options?.indexHint;
112
113 return this;
114 }
115
116 where(sql: string, params: unknown[]): this {
117 this.options.where = { sql, params };

Callers 1

intoMethod · 0.95

Calls 5

quoteMethod · 0.95
usesAsKeywordMethod · 0.80
toRawMethod · 0.45
quoteIdentifierMethod · 0.45
getDefaultSchemaNameMethod · 0.45

Tested by

no test coverage detected