Skip to content

Conversation

fratzinger
Copy link
Contributor

  • .remove() behaves the same way as other methods, do a ._get() with raw: false
  • selector only when necessary
  • update dependencies
  • update tests with NotFound integer id

- .remove() behaves the same way as other methods, do a `._get()` with `raw: false`
- selector only when necessary
- update dependencies
- update tests with NotFound integer id
@fratzinger fratzinger requested a review from DaddyWarbucks June 15, 2024 19:40
@DaddyWarbucks
Copy link
Contributor

DaddyWarbucks commented Jun 17, 2024

I made a couple of comments. But they started getting redundant. I like the new this.select method. The main point I wanted to make is that if we update the select method, It becomes much cleaner to use.

select(data, params) {
  return select(params, this.id)(data) 
}

// If you want to get uber performant, then we can do the  $select
// check ourselves, which would save result.length number of
// useless functions being made and then GC'ed
select(data, params) {
  if (!params.query?.$select?.length) {
    return data;
  }
  return select(params, this.id)(data) 
}


// Then used as
return this.select(results, params)

Then we no longer need to "setup" some select function every method. We can just use this.select(data, params) directly. And, that actually makes this.select a valuable method for the developer to use directly themselves if needed.

All the remove stuff looks good to me!

import { _ } from '@feathersjs/commons';
import {
select as selector,
select as _selector,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just import this as select without having to rename it now. Adding selector as a method cleans up the code/renaming stuff.

const select = isPresent(sequelizeOptions.attributes) ? this.selector(params) : undefined;
const result = instances.map((instance) => {
if (isPresent(sequelizeOptions.attributes)) {
if (select) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we update this.select, then this code simplifies to

if (isPresent(sequelizeOptions.attributes)) {
  return this.select(instance.toJSON(), params);
}

return sequelize;
}

private selector (params?: ServiceParams) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not to be nit-picky about naming stuff, but I think this can be select instead of selector. Like I said above, if we don't have to rename the select import from commons, there is no longer a need to invent a new word selector.

Copy link
Contributor

Choose a reason for hiding this comment

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

Even better. Let's change this to

select(data, params) {
  return select(params, this.id)(data)
}

if (isPresent(sequelizeOptions.attributes)) {
const select = this.selector(params);
const result = instances.map((instance) => {
const result = select(instance.toJSON())
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. If we update this.select, then this code simplifies to

const result = this.select(instance.toJSON(), params)

@DaddyWarbucks
Copy link
Contributor

@fratzinger This seems outdated. But there is some good info here around this.select that should be included in V8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants