r/node 22h ago

MikroORM 7.2: row level security, to-one relations through a pivot, sql.js driver with a live docs playground, cursor pagination rework, and more

Upvotes

MikroORM 7.2 is out — the second minor on top of v7.

New features:

  • Row level security — PostgreSQL policies as entity metadata, created and diffed by the schema generator, with per-request session context pushed down to the connection; an existing @Filter can compile into a policy, so one declaration enforces at both layers
  • through option for to-one relations — resolve a M:1 / 1:1 via a correlated subquery on a pivot entity, or pick a single row out of a to-many relation (e.g. the latest one) without loading the collection
  • sql.js driver — SQLite compiled to WebAssembly, in memory, in the browser, Node.js, Bun and Deno with no native bindings. It also powers the new live playground in the getting-started guide, so the code in the docs runs against a real database as you read it
  • Cursor pagination rework — a new optional Type.fromJSON() lets a custom type own its cursor wire format (sub-millisecond precision survives), and nullable sort keys now make the emitted order by and the keyset condition agree on where nulls sit
  • Named parameters in em.execute():name for values, :name: for identifiers, as an alternative to the positional array
  • String normalization — opt-in trim and casing on StringType / TextType, applied on writes and query parameters
  • getNativeClient() — reach the underlying client for vendor APIs the ORM doesn't wrap: pg Pool, mysql2 Pool, better-sqlite3 / libsql Database, the PGlite instance, MongoClient
  • await using support — the ORM instance implements Symbol.asyncDispose, so the connection closes with the enclosing scope
  • index option on M:N properties — index the generated pivot table's join columns, which had no override on PostgreSQL before
  • Nub TypeScript loader for the CLI, selected explicitly via tsLoader
  • em.map() can bypass the identity map — map raw rows to entities without touching the current context
  • Per-instance options callback for RequestContext.create() — different fork options per ORM instance
  • migrations.snapshotOnMigrate — keep the snapshot managed solely by migration:create instead of rewriting it from the database on migrate
  • CLI -q to suppress informational output, and cache:generate --combined now takes a path

Full blog post: https://mikro-orm.io/blog/mikro-orm-7-2-released
Changelog: https://github.com/mikro-orm/mikro-orm/releases/tag/v7.2.0

Happy to answer any questions!


r/node 23h ago

AirDrop for shell commands

Upvotes

Wanted to share commands instantly with a colleague without losing any encoding so I created this tool, Check it out here https://github.com/darula-hpp/cmdrop


r/node 18h ago

Node not working in Visual Studio

Upvotes

I've recently discovered Tauri and built a project using React which if I run it purely from the terminal it opens up fine, but if I close the terminal and open Visual Studio, open the terminal in VS and run the same thing from the same place I get a Node.js error

In terminal both work correctly:

C:\Users\me\Documents\Tauri_test\react-test> npm run tauri dev (opens the app standalone)
or
C:\Users\me\Documents\Tauri_test\react-test> npm run dev (opens the app in browser)

In Visual Studio running the same lines I get the following:

Node.js v24.20.0
    Error The "beforeDevCommand" terminated with a non-zero status code

I've installed Node from the website and made sure it was added to Visual Studio on install, I've checked that VS can access Node from the 'react-test' folder, I've closed all other open apps in case something is clashing, I get the feeling that something is initialising in the wrong order and that's throwing Node off, but why would it work correctly outside of VS?

(If it doesn't cause issues I'll crosspost this as I don't know which bit of the system is causing the problem)

Solution:

IT WAS THE SODDING VISUAL STUDIO INDEXING

The .vs folder clogs up the system, here's how to get rid of it