Open Akanksha13-dev opened 10 months ago
I tested this one and it looks like you can pass an array of strings for the field names:
const result = await this.certificatesRepository.create(
certificate,
{
fields: [ "a", "b", "c" ]
}
);
The loopback-style syntax would require the "fields" to be remapped here: https://github.com/loopbackio/loopback-next/blob/56201c5505a4e5b5b67022c02c98356a4b864862/extensions/sequelize/src/sequelize/sequelize.repository.base.ts#L170-L176
For example (note that the existing buildSequelizeAttributeFilter has a Typescript interface conflict with the create
parameters):
async create(entity: DataObject<T>, options?: AnyObject): Promise<T> {
const data = await this.sequelizeModel.create(
entity as MakeNullishOptional<T>,
{
...options,
fields: this.buildSequelizeAttributeFilter(options?.fields),
},
);
return new this.entityClass(data.toJSON()) as T;
}
I believe that fields
is a preserved word for the option
and it's of type array. You may try to use another word instead of fields
.
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
Additional information
No response
Reproduction
provided information is enough to understand the problem.