refactor: consistent remove, perf selector, deps, tests by fratzinger · Pull Request #438 · feathersjs-ecosystem/feathers-sequelize · GitHub
Skip to content

refactor: consistent remove, perf selector, deps, tests#438

Open
fratzinger wants to merge 2 commits into
masterfrom
refactor/consistent-remove
Open

refactor: consistent remove, perf selector, deps, tests#438
fratzinger wants to merge 2 commits into
masterfrom
refactor/consistent-remove

Conversation

@fratzinger

Copy link
Copy Markdown
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

DaddyWarbucks commented Jun 17, 2024

Copy link
Copy Markdown
Contributor

Comment thread src/adapter.ts
import { _ } from '@feathersjs/commons';
import {
select as selector,
select as _selector,

Copy link
Copy Markdown
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.

Comment thread src/adapter.ts
const select = isPresent(sequelizeOptions.attributes) ? this.selector(params) : undefined;
const result = instances.map((instance) => {
if (isPresent(sequelizeOptions.attributes)) {
if (select) {

Copy link
Copy Markdown
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);
}

Comment thread src/adapter.ts
return sequelize;
}

private selector (params?: ServiceParams) {

Copy link
Copy Markdown
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
Copy Markdown
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)
}

Comment thread src/adapter.ts
if (isPresent(sequelizeOptions.attributes)) {
const select = this.selector(params);
const result = instances.map((instance) => {
const result = select(instance.toJSON())

Copy link
Copy Markdown
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
Copy Markdown
Contributor

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