我有一個(gè)report_data屬于daily_entry表的表但是當(dāng)我打電話api想要獲取daily_entry表的所有數(shù)據(jù)時(shí)它發(fā)送如下響應(yīng)輸出{ "response_code": "0", "message": "Operation is successfully executed", "status": "success", "data": { "id": 1, "user_id": 1, "date": "12-10-2020", other data .... "is_active": true, "createdAt": "2020-10-21T06:25:57.877Z", "updatedAt": "2020-10-21T06:25:57.877Z", "report_datum": { "id": 1, "entry_i": 1, <<<<<<<----------OUTPUT "Date": null, "report_document_id": "2", "createdAt": "2020-10-21T06:26:02.642Z", "updatedAt": "2020-10-21T06:26:02.642Z" } }, "level": "info", "timestamp": "2020-10-21T06:25:45.947Z"}預(yù)期的{ "response_code": "0", "message": "Operation is successfully executed", "status": "success", "data": { "id": 1, "user_id": 1, "date": "12-10-2020", other data .... "is_active": true, "createdAt": "2020-10-21T06:25:57.877Z", "updatedAt": "2020-10-21T06:25:57.877Z", "report_data": { "id": 1, "entry_id": 1,<<<<<-------------EXPECTED "Date": null, "report_document_id": "2", "createdAt": "2020-10-21T06:26:02.642Z", "updatedAt": "2020-10-21T06:26:02.642Z" } }, "level": "info", "timestamp": "2020-10-21T06:25:45.947Z"}兩個(gè)表之間的關(guān)系是hasOnedb.daily_entry.hasOne(db.report_data, { onDelete: "cascade", foreignKey: 'entry_id', foreignKeyConstraint: true, targetKey: 'id' });我已經(jīng)記錄了來自數(shù)據(jù)庫的數(shù)據(jù),如下所示 dataValues:{id: 1, entry_i: 1, daily_entry : 8468476, date: 23-10-2020, …} get entry_id:? () {\n return this.get(attribute);\n } undefined我已經(jīng)檢查了我的整個(gè)項(xiàng)目,沒有像這樣的名字entry_i
在 Console.log 和 api 響應(yīng)中獲取外鍵未定義
白衣染霜花
2023-06-09 14:52:04