Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mikro-orm/core

Package Overview
Dependencies
Maintainers
1
Versions
3202
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mikro-orm/core

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.

  • 6.3.14-dev.35
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
245K
increased by2.87%
Maintainers
1
Weekly downloads
 
Created

What is @mikro-orm/core?

@mikro-orm/core is an Object-Relational Mapper (ORM) for Node.js and TypeScript. It provides a powerful and flexible way to interact with databases using JavaScript/TypeScript objects. It supports multiple database drivers, including MySQL, PostgreSQL, SQLite, and MongoDB. The package offers features like entity management, query building, migrations, and more.

What are @mikro-orm/core's main functionalities?

Entity Management

Entity management allows you to define and manage your database entities using decorators. In this example, a `User` entity is defined with `id`, `name`, and `email` properties.

const { Entity, PrimaryKey, Property } = require('@mikro-orm/core');

@Entity()
class User {
  @PrimaryKey()
  id;

  @Property()
  name;

  @Property()
  email;
}

const user = new User();
user.name = 'John Doe';
user.email = 'john.doe@example.com';

Query Building

Query building allows you to perform database operations using a fluent API. In this example, a query is built to find all users with the name 'John Doe'.

const { MikroORM } = require('@mikro-orm/core');

async function main() {
  const orm = await MikroORM.init({
    entities: [User],
    dbName: 'my-db-name',
    type: 'postgresql',
  });

  const userRepository = orm.em.getRepository(User);
  const users = await userRepository.find({ name: 'John Doe' });
  console.log(users);
}

main();

Migrations

Migrations allow you to manage database schema changes over time. In this example, a migration is created and then applied to the database.

const { MikroORM } = require('@mikro-orm/core');

async function main() {
  const orm = await MikroORM.init({
    entities: [User],
    dbName: 'my-db-name',
    type: 'postgresql',
  });

  const migrator = orm.getMigrator();
  await migrator.createMigration(); // creates file Migration20201019195930.ts
  await migrator.up(); // runs all pending migrations
}

main();

Other packages similar to @mikro-orm/core

Keywords

FAQs

Package last updated on 25 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc