当我通过与 mysql 相同的 sequelize 查询时,如何更改我的数据?
mysql查询:
SELECT `ProjectProposal`.`id`,
`ProjectProposal`.`vietnamese_name` AS `vietnameseName`,
`ProjectProposal`.`english_name` AS `englishName`,
`ProjectProposal`.`implementation_months` AS `implementationMonths`,
`ProjectProposal`.`total_expenditure` AS `totalExpenditure`,
`ProjectProposal`.`created_at` AS `createdAt`,
`status`.`id` AS `status.id`,
`status`.`name` AS `status.name`,
`projectProposalResearchFields`.`project_proposals_id` AS `projectProposalResearchFields.projectProposalId`,
`projectProposalResearchFields`.`research_fields_id` AS `projectProposalResearchFields.researchFieldId`,
`projectProposalResearchFields`.`priority` AS `projectProposalResearchFields.priority`,
`projectProposalResearchFields`.`research_line` AS `projectProposalResearchFields.researchLine`,
`projectProposalResearchFields`.`deleted_at` AS `projectProposalResearchFields.deletedAt`,
`projectProposalResearchFields`.`created_at` AS `projectProposalResearchFields.createdAt`,
`projectProposalResearchFields`.`updated_at` AS `projectProposalResearchFields.updatedAt`,
`researchType`.`id` AS `researchType.id`,
`researchType`.`name` AS `researchType.name`,
`researchType`.`code` AS `researchType.code`
FROM `project_proposals` AS `ProjectProposal`
INNER JOIN `project_proposals_status` AS `status`
ON `ProjectProposal`.`project_proposals_status_id` =
`status`.`id`
AND `status`.`name` = 'revise'
INNER JOIN `project_proposals_research_fields` AS `projectProposalResearchFields`
ON `ProjectProposal`.`id` =
`projectProposalResearchFields`.`project_proposals_id`
AND ( `projectProposalResearchFields`.`deleted_at` IS NULL
AND `projectProposalResearchFields`.`research_fields_id`
IN (
'30ce149a-6db3-4e04-8e8e-7111761d874f',
'cd9b0b91-86fb-4f30-bd7e-68bbe5758e9f',
'897192e0-7910-4d98-a88f-f0f0128f9103',
'275ffd79-239f-4b8b-a9ad-92ed50e95017' ) )
LEFT OUTER JOIN `research_types` AS `researchType`
ON `ProjectProposal`.`research_types_id` =
`researchType`.`id`
LIMIT 0, 10;
后续查询
const projectProposalList = await this.projectProposalRepository.findAll({
attributes: [
'id',
'vietnameseName',
'englishName',
'implementationMonths',
'totalExpenditure',
'createdAt',
],
include: [
{
model: ProjectProposalStatus,
},
{
model: ProjectProposalResearchField,
include: [ResearchField],
},
{
model: ResearchType,
},
],
where: {
[Op.and]: [
{
'$status.name$': ProjectProposalStatusEnum.REVISE,
'$projectProposalResearchFields.researchField.id$': {
[Op.in]: [researchFieldIds],
},
},
],
},
offset: Number(first),
limit: projectProposalsPerPage,
subQuery: false,
order: [['createdAt', 'ASC']],
});
result: {
"id": "0aaa1ab5-8692-4bee-ad2b-3baeb1767d4e",
"vietnameseName": "Cấu trúc nano của vật liệu đa chiều cho các ứng dụng cảm biến quang điện hóa (PEC)",
"englishName": "Multidimensional nanostructures-based for photoelectrochemical sensing applications",
"implementationMonths": 12,
"totalExpenditure": 20000000000,
"createdAt": "2023-03-14T16:45:25.000Z",
"status": {
"id": "897192e0-7910-4d98-a88f-f0f0128f9103",
"name": "revise"
},
"projectProposalResearchFields": [
{
"projectProposalId": "0aaa1ab5-8692-4bee-ad2b-3baeb1767d4e",
"researchFieldId": "275ffd79-239f-4b8b-a9ad-92ed50e95017",
"priority": 1,
"researchLine": "Khoa học Nhân văn",
"deletedAt": null,
"createdAt": null,
"updatedAt": null,
"researchField": {
"id": "275ffd79-239f-4b8b-a9ad-92ed50e95017",
"name": "Khoa học Nhân văn",
"code": "humanity"
}
},
{
"projectProposalId": "0aaa1ab5-8692-4bee-ad2b-3baeb1767d4e",
"researchFieldId": "30ce149a-6db3-4e04-8e8e-7111761d874f",
"priority": 2,
"researchLine": "Khoa học Xã hội",
"deletedAt": null,
"createdAt": null,
"updatedAt": null,
"researchField": {
"id": "30ce149a-6db3-4e04-8e8e-7111761d874f",
"name": "Khoa học Xã hội",
"code": "science"
}
},
{
"projectProposalId": "0aaa1ab5-8692-4bee-ad2b-3baeb1767d4e",
"researchFieldId": "897192e0-7910-4d98-a88f-f0f0128f9103",
"priority": 3,
"researchLine": "Kinh tế, Luật",
"deletedAt": null,
"createdAt": null,
"updatedAt": null,
"researchField": {
"id": "897192e0-7910-4d98-a88f-f0f0128f9103",
"name": "Kinh tế, Luật",
"code": "economic&law"
}
}
],
"researchType": {
"id": "30ce149a-6db3-4e04-8e8e-7111761d874f",
"name": "Nghiên cứu ứng dụng",
"code": "applied"
}
},
{
"id": "2483b145-6732-4e3f-a8dd-4198391b2cf9",
"vietnameseName": "Nhận dạng và điều khiển thích nghi các hệ phi tuyến đa biến ứng dụng các thuật toán lai thông minh điều khiển tối ưu nâng cao.",
"englishName": "Identification and control of nonlinear multivariable systems using advanced hybrid optimal control intelligence algorithms",
"implementationMonths": 12,
"totalExpenditure": 20000000000,
"createdAt": "2023-03-14T16:45:25.000Z",
"status": {
"id": "897192e0-7910-4d98-a88f-f0f0128f9103",
"name": "revise"
},
"projectProposalResearchFields": [
{
"projectProposalId": "2483b145-6732-4e3f-a8dd-4198391b2cf9",
"researchFieldId": "275ffd79-239f-4b8b-a9ad-92ed50e95017",
"priority": 1,
"researchLine": "Khoa học Nhân văn",
"deletedAt": null,
"createdAt": null,
"updatedAt": null,
"researchField": {
"id": "275ffd79-239f-4b8b-a9ad-92ed50e95017",
"name": "Khoa học Nhân văn",
"code": "humanity"
}
}
],
"researchType": {
"id": "30ce149a-6db3-4e04-8e8e-7111761d874f",
"name": "Nghiên cứu ứng dụng",
"code": "applied"
}
}
{
"id": "0aaa1ab5-8692-4bee-ad2b-3baeb1767d4e",
"vietnameseName": "Cấu trúc nano của vật liệu đa chiều cho các ứng dụng cảm biến quang điện hóa (PEC)",
"englishName": "Multidimensional nanostructures-based for photoelectrochemical sensing applications",
"implementationMonths": 12,
"totalExpenditure": 20000000000,
"createdAt": "2023-03-14T16:45:25.000Z",
"status": {
"id": "897192e0-7910-4d98-a88f-f0f0128f9103",
"name": "revise"
},
"projectProposalResearchFields": [
{
"projectProposalId": "0aaa1ab5-8692-4bee-ad2b-3baeb1767d4e",
"researchFieldId": "275ffd79-239f-4b8b-a9ad-92ed50e95017",
"priority": 1,
"researchLine": "Khoa học Nhân văn",
"deletedAt": null,
"createdAt": null,
"updatedAt": null,
"researchField": {
"id": "275ffd79-239f-4b8b-a9ad-92ed50e95017",
"name": "Khoa học Nhân văn",
"code": "humanity"
}
},
{
"projectProposalId": "0aaa1ab5-8692-4bee-ad2b-3baeb1767d4e",
"researchFieldId": "30ce149a-6db3-4e04-8e8e-7111761d874f",
"priority": 2,
"researchLine": "Khoa học Xã hội",
"deletedAt": null,
"createdAt": null,
"updatedAt": null,
"researchField": {
"id": "30ce149a-6db3-4e04-8e8e-7111761d874f",
"name": "Khoa học Xã hội",
"code": "science"
}
},
{
"projectProposalId": "0aaa1ab5-8692-4bee-ad2b-3baeb1767d4e",
"researchFieldId": "897192e0-7910-4d98-a88f-f0f0128f9103",
"priority": 3,
"researchLine": "Kinh tế, Luật",
"deletedAt": null,
"createdAt": null,
"updatedAt": null,
"researchField": {
"id": "897192e0-7910-4d98-a88f-f0f0128f9103",
"name": "Kinh tế, Luật",
"code": "economic&law"
}
}
],
"researchType": {
"id": "30ce149a-6db3-4e04-8e8e-7111761d874f",
"name": "Nghiên cứu ứng dụng",
"code": "applied"
}
},
{
"id": "2483b145-6732-4e3f-a8dd-4198391b2cf9",
"vietnameseName": "Nhận dạng và điều khiển thích nghi các hệ phi tuyến đa biến ứng dụng các thuật toán lai thông minh điều khiển tối ưu nâng cao.",
"englishName": "Identification and control of nonlinear multivariable systems using advanced hybrid optimal control intelligence algorithms",
"implementationMonths": 12,
"totalExpenditure": 20000000000,
"createdAt": "2023-03-14T16:45:25.000Z",
"status": {
"id": "897192e0-7910-4d98-a88f-f0f0128f9103",
"name": "revise"
},
"projectProposalResearchFields": [
{
"projectProposalId": "2483b145-6732-4e3f-a8dd-4198391b2cf9",
"researchFieldId": "275ffd79-239f-4b8b-a9ad-92ed50e95017",
"priority": 1,
"researchLine": "Khoa học Nhân văn",
"deletedAt": null,
"createdAt": null,
"updatedAt": null,
"researchField": {
"id": "275ffd79-239f-4b8b-a9ad-92ed50e95017",
"name": "Khoa học Nhân văn",
"code": "humanity"
}
}
],
"researchType": {
"id": "30ce149a-6db3-4e04-8e8e-7111761d874f",
"name": "Nghiên cứu ứng dụng",
"code": "applied"
}
}
总记录为2
希望大家能帮帮我,非常感谢