undeexcepturi
Version:
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.
33 lines (26 loc) • 931 B
Markdown
title: Debugging
For development purposes it might come handy to enable logging and debug mode:
```typescript
return MikroORM.init({
logger: console.log.bind(console),
debug: true,
});
```
By doing this `MikroORM` will start using provided logger function to dump all queries:
```
[query-logger] SELECT `e0`.* FROM `author` AS `e0` WHERE `e0`.`name` = ? LIMIT ? [took 2 ms]
[query-logger] START TRANSACTION [took 1 ms]
[query-logger] INSERT INTO `author` (`name`, `email`, `created_at`, `updated_at`, `terms_accepted`) VALUES (?, ?, ?, ?, ?) [took 2 ms]
[query-logger] COMMIT [took 2 ms]
```
It is also useful for debugging problems with entity discovery, as you will see information about every processed entity:
```
ORM entity discovery started
- processing entity Author
- using cached metadata for entity Author
- processing entity Book
- processing entity BookTag
- entity discovery finished after 13 ms
```