Skip to content

Conversation

@jskiller1404
Copy link
Contributor

No description provided.

Copy link
Member

@fruneen fruneen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jskiller1404 oh, we thought about different implantations.
I see this feature as saving current method 'getPublic', details are in this ticket: https://github.com/orgs/paralect/projects/1?pane=issue&itemId=62396152

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that features will be on node-mongo beta right now, could you please rollback it?
When I publish changes, I will add these changes to the doc

Comment on lines 993 to 995
getPublic = <U extends T = T>(doc: U | null): Partial<U> | null => {
return omitPrivateFields<U>(doc, this.options.privateFields || []);
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please play with return type?
Ideally, If you pass a user with type { _id: string, password: string } and private fields ['password'] return type should be { _id: string } (accessing 'password' field should cause error)

also try to implement types overloading when you pass null, here is high-level example:

interface MyObject {
  foo: string;
  bar: number;
}

// Modified type example
interface ModifiedObject {
  foo: string;
  bar: number;
  baz: boolean;
}

// Overloads
function processObj(obj: null): null;
function processObj(obj: MyObject): ModifiedObject;

// Implementation (single signature)
function processObj(obj: MyObject | null): ModifiedObject | null {
  if (obj === null) return null;
  // Modify object as needed
  return { ...obj, baz: true };
}

@jskiller1404 jskiller1404 force-pushed the jskiller1404/add-ommiting-private-fields-feature branch 2 times, most recently from a1cd5dd to 0e0c6f6 Compare November 25, 2025 07:28
@jskiller1404 jskiller1404 force-pushed the jskiller1404/add-ommiting-private-fields-feature branch from 0e0c6f6 to bf6db6d Compare November 25, 2025 07:29
@jskiller1404 jskiller1404 requested a review from fruneen November 25, 2025 07:30
Copy link
Member

@fruneen fruneen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

I'll merge it after testing on my side with new release version of node-mongo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants