2016-04-15 32 views
1

私は問合せに問題があります。アソシエーションの関連付けを続ける

私のコードは他の状態1とBookingFeedbackMaster中に存在する任意の行が、それは私に何も出力を与えない場合にはうまく機能

db.Doctor.findAll({ 
    attributes : ['id','firstName','lastName', 
        'profilePicture','education','experience', 
        'fees','gender','mobile','email'], 
    include: [ 
     { model : db.Category, attributes : ['title']}, 
     { model : db.Area, attributes : ['name']}, 
     { model : db.City, attributes : ['name']}, 
     { model : db.State, attributes : ['name']}, 
     { model : db.Country, attributes : ['name']}, 
     { model : db.DoctorClinicPicture, attributes : ['imagePath']}, 
     { 
      model : db.BookingFeedbackMaster, 
      attributes : ['rating','comment'], 
      where : { status: 1 } 
     } 
    ], 
    where : { id: req.query.doctorId}, 
    order: 'id ASC' 
}).then(function(data){ 

    if (data != null) 
    { 
     res.json({status:true,msg:"Doctor viewed successfully!!",data:data});  
    } 
    else 
    { 
     res.json({status:true,msg:"Doctor is temporary not available",data:""});   
    } 

}).catch(function(err){ 
    res.json({status:"fail"}); 
}); 

です。

他のデータを取得する必要があります。私はBookingFeedbackMasterデータを取得していない場合、メーターはありません。条件が一致しない場合

誰かを助けてください。

ありがとうございます。

答えて

2

BookingFeedbackMasterrequired: falseと照会してください。この方法では、内部結合ではなく、左外部結合を実行しています

+0

はい、ありがとうございます。今私はクエリのように作る必要があります: 'abc'で始まるエリアまたは 'abc。'で始まる都市それを行う方法はありますか?だから、私はdatatable jqueryプラグインで使用することができます。 – divyang

+0

はい。たとえば、 'abc'で始まる名前を照会するには、 'name:{$ like: 'abc%'} 'を使用します。 –

+0

実際には、検索ボックスがあり、すべてのフィールドに一致させる必要があります。ドクター・テーブルからのfirstname、カテゴリー・テーブルからのタイトルなど。私を助けてください。 – divyang

関連する問題