如何编辑发布函数以发布到引用其他架构的架构中? 我想使用异步等待 这是我的发布方法:
export const post: Operation = async(req: express.Request, res: express.Response) => {
commonUtility.showRequestParam(req);
let tasks: db.ITaskDocument[] = [];
};
这是我要发布到的任务模式:
export const taskSchema = new Schema ({
user: {
type: mongoose.Schema.Types.ObjectId,
ref: 'users',
required: true
},
issue: {
type: mongoose.Schema.Types.ObjectId,
ref: 'issues',
required: true
},
record: {
development: {
type: Number
},
test:{
type: Number
},
votary:{
type: Number
}
},
date: {
type: Date,
required: true
},
BaseFields
});
export const TaskModel = mongoose.model<db.ITaskDocument>('Tasks', taskSchema);
问题模式:
const issuesSchema = new Schema({
project: {
type: mongoose.Schema.Types.ObjectId,
ref: 'projects',
required: true
},
number: {
type: String
},
title: {
type: String
},
BaseFields
});
export const IssueModel = mongoose.model<db.IIssueDocument>('Issues', issuesSchema);
用户架构:
export const usersSchema = new Schema({
username: {
type: String,
required: true
},
email: {
type: String,
required: true
},
password: {
type: String,
required: true
},
BaseFields
});
export const UserModel = mongoose.model<db.IUserDocument>('Users', usersSchema);
我也希望对如何使用async-await创建put函数有一个简短的想法。