Is it possible to omit certain fields when using the select function in MikroORM?

When working with nested populate queries in MikroORM with MySQL, I am faced with the challenge of selecting 100 fields while wanting to exclude around 20 fields. It would make more sense to leave out those 20 fields, similar to using db.find().select("-password") in MongoDB. However, the documentation only seems to cover Partial Fetches for selecting fields, not unselecting them.

Answer №1

Starting from version 6.0.0, you have the ability to utilize the exclude option, allowing you to omit specific properties while selecting all others.

const userWithoutEmail = await em.findOne(User, '...', {
  exclude: ['email']
});

Answer №2

The instruction manual includes a functionality for concealing fields that you wish to keep hidden.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the most suitable database for my specific application needs? Should I go for MySQL, MongoDB, PostgreSQL, or Couch

As I develop my Node.js application, I am facing the challenge of storing a vast amount of data efficiently. Utilizing cluster and async modules, I aim to fully optimize my system. Let's take a look at the specifications of my setup: Workstation: ...

Instead of returning an object, the underscore groupBy function now returns an array

Currently, I am attempting to utilize underscore to create an array of entities that are grouped by their respective locations. The current format of the array consists of pairs in this structure { location: Location, data: T}[]. However, I aim to rearran ...

I am losing my mind over this PHP error

Recently, I encountered an error that is giving me a hard time. The error message reads: [25-May-2013 06:15:43] PHP Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/eightcoz/public_html/doyourbit/match.php on line 6 In ...

After updating the file path, the Next.Js module couldn't be located: Module not found – Unable to

After relocating the EmptyTable.tsx file from its original directory at views/forms-tables/tables/react-table/EmptyTable to a new location at components/Tables/EmptyTable, I encountered a persistent issue. Despite updating the import path in my code to mat ...

Accessing props in setup function in Vue 3

I am encountering issues when trying to access the props value (an array) in my composition API setup. The component I have is called DropDown, and I am passing it an array of objects. Here's what I need to achieve: export default { emits: ['up ...

Guide on integrating Mapbox GL Draw into an Angular 8 project

I'm currently working on an Angular 8 project that utilizes Webpack. My integration of Mapbox GL JS was successful, however, I am facing issues with importing Mabox GL Draw. Here are the versions I am using: "@angular/core": "8.2.14", "mapbox-gl": "^ ...

The ESLint tool seems to be struggling to detect the package named "@typescript-eslint/eslint-plugin"

Struggling with getting ESLint to function properly on a new Angular project in VS Code. The error message I keep encountering is about failing to load "@typescript-eslint/eslint-plugin". After spending the past 3 hours troubleshooting, I have searched hig ...

Having difficulty updating an angular variable within a callback function

Currently, I am utilizing the Google Maps directions service to determine the estimated travel time. this.mapsAPILoader.load().then(() => { const p1 = new google.maps.LatLng(50.926217, 5.342043); const p2 = new google.maps.LatLng(50.940525, 5.35362 ...

Having trouble with a PHP MySQL issue while trying to upload a picture to a blob field? You may be

After reading numerous threads and trying different solutions, I am still facing an issue with uploading a picture using blob. Despite passing the file, $_FILES['picture'] is not being set. Even when attempting $imageName = $_FILES['picture& ...

Determining the type relationship between two generic types when using a union

Here is the code snippet defining a React component using react-hook-form: import { type FieldPath, type FieldValues, type FieldPathValue, } from "react-hook-form"; interface FormControlRadioBoxProps< TFieldValues extends FieldValue ...

Utilizing Typescript Decorators to dynamically assign instance fields within a class for internal use

I am interested in delving into Typescript Decorators to enhance my coding skills. My primary objective is to emulate the functionality of @Slf4J from Project Lombok in Java using Typescript. The concept involves annotating/decorating a class with somethin ...

Unexpected results encountered when executing MySQL query

Greetings! I am currently working on writing a MySQL query for a database with the following structure: Professor (EMP ID, Name, Status, Salary, Age) Course (Course ID, Course Name, Points) Works (Course ID, EMP ID, Class ID) Assumptions: - Each course h ...

Establishing a Next.js API endpoint at the root level

I have a webpage located at URL root, which has been developed using React. Now, I am looking to create an API endpoint on the root as well. `http://localhost:3000/` > directs to the React page `http://localhost:3000/foo` > leads to the Next API end ...

Utilizing Angular 2 for Integration of Google Calendar API

I recently attempted to integrate the Google Calendar API with Angular 2 in order to display upcoming events on a web application I am developing. Following the Google Calendar JavaScript quick-start tutorial, I successfully managed to set up the API, inse ...

Organize by name while preserving all tags linked to each name

I'm curious if anyone has encountered the following: SQL Query: SELECT s.ID , s.name , s.artist, m.tag_ID, t.name, s.*, m.*, t.* FROM lms_song s LEFT JOIN lms_map m ON s.ID = m.ID LEFT ...

Transfer text between Angular components

Here is the landing-HTML page that I have: <div class="container"> <div> <mat-radio-group class="selected-type" [(ngModel)]="selectedType" (change)="radioChange()"> <p class="question">Which movie report would you like ...

Testing a PHP scheduling program is essential to ensure its functionality and effectiveness. Follow

On my codeigniter app, I have a feature that schedules events for specific dates and times in a MySQL database. These events can be scheduled weeks in advance, and there is also functionality to send email reminders and perform other actions when these d ...

Angular2 - Transforming SVG elements with dynamic styles using ng-style

I'm trying to create SVG lines using ng-repeat and need to adjust the translation of each line. However, I'm having trouble getting the style to apply using ng-attr-style. my-component.js: import {Component} from 'angular2/core'; @Co ...

How to show specific images by clicking on particular items in Ionic 3 on a separate page

Can someone assist me with displaying specific images from a slider gallery? I am struggling to figure out how to show only the January edition when clicking on it in eighteen.html, while hiding the February and March editions. It has been 2 days of unsucc ...

Modify the button input value within a PHP script

I am currently working on a piece of code that involves following different users and inserting values from a MySQL table. <td align="center"> <input type="button" name="<?php echo $id; ?>" id="<?php ech ...