Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@mikro-orm/sql

Package Overview
Dependencies
Maintainers
1
Versions
605
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mikro-orm/sql - npm Package Compare versions

Comparing version
7.1.0-dev.34
to
7.1.0-dev.35
+2
-2
package.json
{
"name": "@mikro-orm/sql",
"version": "7.1.0-dev.34",
"version": "7.1.0-dev.35",
"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.",

@@ -56,3 +56,3 @@ "keywords": [

"peerDependencies": {
"@mikro-orm/core": "7.1.0-dev.34"
"@mikro-orm/core": "7.1.0-dev.35"
},

@@ -59,0 +59,0 @@ "engines": {

@@ -34,3 +34,24 @@ import { type AbortQueryOptions, type EntitySchemaWithMeta, EntityManager, type AnyEntity, type ConnectionType, type CountByOptions, type Dictionary, type EntityData, type EntityKey, type EntityName, type EntityRepository, type FilterQuery, type GetRepository, type LoggingOptions, type QueryResult, type RawQueryFragment } from '@mikro-orm/core';

/**
* Returns configured Kysely instance.
* Returns a configured Kysely instance bound to this EntityManager.
*
* When the EntityManager is inside a transaction (e.g. within `em.transactional(...)`, or after
* `em.begin()`), the returned Kysely instance automatically uses the transaction context, so any
* queries executed via Kysely's own `.execute()` / `.executeTakeFirst*()` participate in the
* current transaction.
*
* If you need a Kysely instance that is **not** bound to the current transaction (e.g. to perform
* a side query against the pool while inside a transactional block), fork the EntityManager first:
*
* ```ts
* await em.transactional(async em => {
* // bound to the current transaction
* await em.getKysely().selectFrom('user').selectAll().execute();
*
* // bound to the pool, runs outside the transaction
* await em.fork().getKysely().selectFrom('audit_log').selectAll().execute();
* });
* ```
*
* The `options.type` (`'read'` / `'write'`) is only honored outside a transaction — inside a
* transaction the connection is already pinned.
*/

@@ -37,0 +58,0 @@ getKysely<TDB = undefined, TOptions extends GetKyselyOptions = GetKyselyOptions>(options?: TOptions): Kysely<TDB extends undefined ? InferKyselyDB<EntitiesFromManager<this>, TOptions> & InferClassEntityDB<AllEntitiesFromManager<this>, TOptions> : TDB>;

@@ -23,6 +23,29 @@ import { EntityManager, raw, Utils, } from '@mikro-orm/core';

/**
* Returns configured Kysely instance.
* Returns a configured Kysely instance bound to this EntityManager.
*
* When the EntityManager is inside a transaction (e.g. within `em.transactional(...)`, or after
* `em.begin()`), the returned Kysely instance automatically uses the transaction context, so any
* queries executed via Kysely's own `.execute()` / `.executeTakeFirst*()` participate in the
* current transaction.
*
* If you need a Kysely instance that is **not** bound to the current transaction (e.g. to perform
* a side query against the pool while inside a transactional block), fork the EntityManager first:
*
* ```ts
* await em.transactional(async em => {
* // bound to the current transaction
* await em.getKysely().selectFrom('user').selectAll().execute();
*
* // bound to the pool, runs outside the transaction
* await em.fork().getKysely().selectFrom('audit_log').selectAll().execute();
* });
* ```
*
* The `options.type` (`'read'` / `'write'`) is only honored outside a transaction — inside a
* transaction the connection is already pinned.
*/
getKysely(options = {}) {
let kysely = this.getConnection(options.type).getClient();
const context = this.getContext(false);
const ctx = context.getTransactionContext();
let kysely = ctx ?? this.getConnection(options.type).getClient();
if (options.columnNamingStrategy != null ||

@@ -29,0 +52,0 @@ options.tableNamingStrategy != null ||