loopbackio / loopbackio/loopback-next

Options param in SequelizeRepository create methods issue

Open
#10,278 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug sequelize
Dominant language
TypeScript
Stars
5.1k
Forks
1.1k
Avg merge
2d 21h
Merged PRs (30d)
27

Description

### Describe the bug

options = {
fields: {
privateKey: false,
publicKey: false,
},
};

const result = await this.certificatesRepository.create(
certificate,
this.options,
);
when we pass this.option param in create method getting error options.attributes.map is not a function. But working for findById.

### Logs

```shell
[2023-12-28T08:09:29.630Z] error :: App_Log -> Request POST /tenants/f5408ba4-521f-4f96-fe87-bf0e6092ea16/certificates/ errored out. Error :: {} TypeError: options.attributes.map is not a function
Request POST /tenants/f5408ba4-521f-4f96-fe87-bf0e6092ea16/certificates/ failed with status code 500. TypeError: options.attributes.map is not a function
at new Model (/Users/akanksha.singh/Desktop/telescope/telescope-health-backend-api/node_modules/sequelize/src/model.js:117:47)
at new certificates (/Users/akanksha.singh/Desktop/telescope/telescope-health-backend-api/node_modules/sequelize/src/sequelize.js:466:19)
at Function.build (/Users/akanksha.singh/Desktop/telescope/telescope-health-backend-api/node_modules/sequelize/src/model.js:2255:12)
at Function.create (/Users/akanksha.singh/Desktop/telescope/telescope-health-backend-api/node_modules/sequelize/src/model.js:2305:23)
at CertificatesRepository.create (/Users/akanksha.singh/Desktop/telescope/telescope-health-backend-api/node_modules/@loopback/sequelize/src/sequelize/sequelize.repository.base.ts:151:44)
at CertificatesRepository.create (/Users/akanksha.singh/Desktop/telescope/telescope-health-backend-api/node_modules/@sourceloop/core/src/repositories/sequelize/sequelize-user-modify-crud.repository.base.ts:41:18)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at CommonHelperService.createCertificate (/Users/akanksha.singh/Desktop/telescope/telescope-health-backend-api/services/cbi-service/src/services/common-helper.service.ts:112:20)
at ServiceSequence.handle (/Users/akanksha.singh/Desktop/telescope/telescope-health-backend-api/node_modules/@sourceloop/core/src/service-sequence.ts:113:22)
at HttpHandler._handleRequest (/Users/akanksha.singh/Desktop/telescope/telescope-health-backend-api/node_modules/@loopback/rest/src/http-handler.ts:115:5)
[2023-12-28T08:09:29.652Z] info :: App_Log -> Request POST /tenants/f5408ba4-521f-4f96-fe87-bf0e6092ea16/certificates/ Completed in 1895ms
```

### Additional information

_No response_

### Reproduction

provided information is enough to understand the problem.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at SequelizeRepository.create in @loopback/sequelize/src/sequelize/sequelize.repository.base.ts and follow the options passed through @sourceloop/core/src/repositories/sequelize/sequelize-user-modify-crud.repository.base.ts. Reproduce the failure from CommonHelperService.createCertificate and compare create with findById; done means the supplied options no longer produce an options.attributes.map error.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.