मैंने typeorm
querybuilder
विकसित किया है। डिबगिंग के उद्देश्य के लिए, मैं एसक्यूएल दिखाना चाहता हूं।
मैंने printSql()
विधि का परीक्षण किया। लेकिन इसने कोई एसक्यूएल नहीं दिखाया।
const Result = await this.attendanceRepository
.createQueryBuilder("attendance")
.innerJoin("attendance.child", "child")
.select(["attendance.childId","child.class","CONCAT(child.firstName, child.lastName)"])
.where("attendance.id= :id", { id: id})
.printSql()
.getOne()
console.log(Result);
यह निम्नलिखित लौट आया।
Attendance { childId: 4, child: Child { class: 'S' } }
मेरा वांछित परिणाम SQL
प्राप्त करना है
क्या कोई गलत बिंदु है? एसक्यूएल पाने का कोई अच्छा तरीका है?
अगर किसी की राय है तो कृपया मुझे बताएं।
धन्यवाद
1 उत्तर
.getQuery()
या .getSql()
const sql1 = await this.attendanceRepository
.createQueryBuilder("attendance")
.innerJoin("attendance.child", "child")
.select(["attendance.childId","child.class","CONCAT(child.firstName, child.lastName)"])
.where("attendance.id= :id", { id: id})
.getQuery();
console.log(sql1);
const sql2 = await this.attendanceRepository
.createQueryBuilder("attendance")
.innerJoin("attendance.child", "child")
.select(["attendance.childId","child.class","CONCAT(child.firstName, child.lastName)"])
.where("attendance.id= :id", { id: id})
.getSql();
console.log(sql2);
संबंधित सवाल
नए सवाल
sql
संरचित क्वेरी भाषा (एसक्यूएल) डेटाबेस को क्वेरी करने के लिए एक भाषा है। प्रश्नों में कोड उदाहरण, तालिका संरचना, नमूना डेटा और DBMS कार्यान्वयन के लिए एक टैग (जैसे MySQL, PostgreSQL, Oracle, MS SQL Server, IBM DB2, आदि) का उपयोग किया जाना चाहिए। यदि आपका प्रश्न केवल एक विशिष्ट DBMS (विशिष्ट एक्सटेंशन / सुविधाओं का उपयोग करता है) से संबंधित है, तो इसके बजाय उस DBMS के टैग का उपयोग करें। एसक्यूएल के साथ टैग किए गए सवालों के जवाब में आईएसओ / आईईसी मानक एसक्यूएल का उपयोग करना चाहिए।