I am using typeorm join without making relation in tables. This my query:
let query = userRepository.createQueryBuilder("u")
.where("u.academicYear = :year", { year })
.leftJoinAndMapOne("u.educationalDetails", EducationalDetails, "e", "u.id = e.userId")
.leftJoinAndMapOne("u.preferences", Preferences, "p", "u.id = p.userId")
.leftJoinAndMapOne("u.phdEducationalDetails", PhdEducationalDetails, "ep", "u.id = ep.userId")
.leftJoinAndMapOne("u.order", Order, "o", "u.serialNo = o.serialNo");
User {
id: 15,
firstName: 'moin',
lastName: 'prajapati',
nameAsOnMarksheet: 'moin prajapati',
email: '[email protected]',
mobileno: '7666126606',
dob: '2002-01-06',
gender: 'Male',
bloodGroup: 'O+',
nameAsPerAadharCard: 'mahesh prajapati',
aadharCardno: '741258369789',
corCity: 'Mumbai',
corState: 'Maharashtra',
corAddress: 'malad',
religion: 'Hinduism',
minority: 'Hindu',
corPincode: '400095',
motherName: 'mother',
fatherName: 'father',
guardianMobileno: '7666126606',
parentsMobileno: null,
admissionType: 'PHD',
admissionCategory: 'Open/General',
admissionSubCategory: 'Not Applicable',
role: 'STUDENT',
keycloakId: 'dd0cd351-0def-4490-91bc-2e8fc1e7a695',
pinPurchase: 'ugix4GviB5Bv',
status: 'ACTIVE',
serialNo: null,
registrationNo: 600005,
imagesName: null,
learningDisability: 'NOT APPLICABLE',
category: 'General',
academicYear: 2024,
registerYear: '2024',
preAddress: 'malad',
prePincode: '400095',
preCity: 'Mumbai',
preState: 'Maharashtra',
isAddressSame: 'Yes',
nationality: 'India',
familyAnnualIncome: null,
otp: null,
otpVerified: false,
otherReligion: null,
placeOfBirth: 'India',
abcId: null,
createdAt: 2024-05-04T06:00:43.423Z,
updatedAt: 2024-05-08T10:52:02.103Z,
corTaluka: null,
guardianAnnualIncome: '50,001 to 2,00,000',
employeeStatus: null,
preCountry: null,
whatsAppno: null,
isWhatsappNoSame: null,
domicileState: null,
educationalDetails: [EducationalDetails],
preferences: [Preferences],
phdEducationalDetails: null,
order: null
},
This how I am getting the result. I want it all in one object. Can we do that? In this I am getting in array then object
Can I solve this issue in one object? Also I can’t use the relation. I want to do it without any relationship in them
Amina Shaikh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
without making relationship to table unable to join the table using Type Orm
refer these link
How to make Inner Join to work on TypeORM?