New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mikro-orm-plus

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mikro-orm-plus

Some useful features for MikroORM

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-71.43%
Maintainers
1
Weekly downloads
 
Created
Source

mikro-orm-plus

Some useful features for MikroORM

Installation

$ npm install mikro-orm-plus
$ yarn add mikro-orm-plus
$ pnpm install mikro-orm-plus

@CreateDateProperty

Special property that is automatically set to the entity's insertion time. You don't need to write a value into this property - it will be automatically set.

import { Entity, PrimaryKey, Property } from '@mikro-orm/core';
import { CreateDateProperty } from 'mikro-orm-plus';

@Entity()
export class User {

  @PrimaryKey()
  id!: number;

  @Property()
  name!: string;

  @CreateDateProperty()
  createdAt: Date;

}

@UpdateDateProperty

Special property that is automatically set to the entity's update time. You don't need to write a value into this property - it will be automatically set.

import { Entity, PrimaryKey, Property } from '@mikro-orm/core';
import { UpdateDateProperty } from 'mikro-orm-plus';

@Entity()
export class User {

  @PrimaryKey()
  id: number;

  @Property()
  name: string;

  @UpdateDateProperty()
  updatedAt: Date;

}

@DeleteDateProperty

Special property that is automatically set to the entity's delete time. You don't need to write a value into this property - it will be automatically set.

This feature is base on mikro-orm-soft-delete, modified as a property decorator implementation.

Soft deletable entity define:

import { Entity, PrimaryKey, Property } from '@mikro-orm/core';
import { DeleteDateProperty } from 'mikro-orm-plus';

@Entity()
export class User {

  @PrimaryKey()
  id: number;

  @Property()
  name: string;

  @DeleteDateProperty()
  deletedAt: Date;

}

how to softly delete?

Consistent with mikroOrm's api, just use em.remove() or em.removeAndFlush() to delete entity.

await em.removeAndFlush(user);

How to find soft deleted entity?

You need disabled soft delete filter, and then you can find soft deleted entity.

em.find(User, {...}, { filters: { [SOFT_DELETABLE_FILTER]: false } });
em.find(User, {...}, { filters: false }); // if you are sure that there are no other filters enabled

How to hard delete entity?

You can use em.nativeDelete() to hard delete entity.

License

MIT licensed.

FAQs

Package last updated on 18 Jan 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