我想在一个查询中插入10个条目,而对10个查询。
我需要设置一些东西吗?我根本不知道该怎么办。
带样本回购:https://github.com/mathias22osterhagen22/loopback-array-post-sample
编辑:people-model.ts:
import {Entity, model, property} from '@loopback/repository';
@model()
export class People extends Entity {
@property({
type: 'number',
id: true,
generated: true,
})
id?: number;
@property({
type: 'string',
required: true,
})
name: string;
constructor(data?: Partial<People>) {
super(data);
}
}
export interface PeopleRelations {
// describe navigational properties here
}
export type PeopleWithRelations = People & PeopleRelations;
async create(
@requestBody({
content: {
'application/json': {
schema: {
type: 'array',
items: getModelSchemaRef(People, {
title: 'NewPeople',
exclude: ['id'],
}),
}
},
},
})
...restof logic
您可以通过修改请求主体来传递人员模型的数组。如果需要更多帮助,可以发表评论。 “快乐回送:)”