2016-09-15 3 views
0

를 반환, 나는 이것이 ReQL 사용할 수 있어요 내가 분리하고 단지 'prescriptions' 배열을 검색하는 쿼리에 pluck 또는 getField 기능을 추가 할 때 형식은 ... 는 .getField() <code>Node.js</code> 및 <code>Rethink</code>의 <code>RethinkdbDash</code> 패키지를 사용하여 빈 결과

{ 
    "address": "<ADDRESS>" , 
    "createdAt": Thu Sep 15 2016 02:08:54 GMT+00:00 , 
    "email": <EMAIL>, 
    "firstName": "<FIRST NAME>" , 
    "fullName": "<FULL NAME>" , 
    "lastName": "<LAST NAME>" , 
    "middleName": "<MIDDLE NAME>" , 
    "phone": "<PHONE NUMBER>" , 
    "prescriptions": [ 
    { 
     "expiresOn": Thu Sep 15 2016 00:00:00 GMT+00:00 , 
     "hasExpired": false , 
     "name": "<MEDICATION NAME>" , 
     "prescribedBy": "<DOCTOR NAME>" , 
     "prescribedOn": Thu Sep 15 2016 02:54:52 GMT+00:00 , 
     "startOn": Thu Sep 15 2016 02:54:52 GMT+00:00 , 
     "uuid": "f11fed84-30dc-4cf9-af36-b715f303bed1" 
     } 
    ] , 
    "uuid": "bd4d6d44-3af3-4224-afef-d7e9a876025b" 
} 

문제

온다. 내가 액세스에게 API로이 데이터를 호출하고, 내가받을 다음과 같은 응답 all 기능을 실행하면이 ... 호출에 대한 내 컨트롤러의 기능 ...

export function all(req, res) { 
    let id = req.params.id 

    r.table('Patients').get(id).pluck('prescriptions').run() //Also tried .getField('prescriptions') and .get(id)('prescriptions') 
    .then((results) => { 
     console.log(results) 
     return res.json({ status: 200, data: results }) 
    }) 
    .catch((error) => { 
     console.log(error) 
     return res.json({ status: 400, message: 'There was an error finding the medication of patient ' + id, data: error }) 
    }) 
} 

입니다

{ 
    status: 200, 
    data: [] 
} 

그러나 정확히 동일한 쿼리는 Rethink 관리 콘솔의 데이터 탐색기에서 예상대로 작동합니다.

왜 이런 일이 벌어지고 있는지에 대한 아이디어 나 도움은 크게 감사드립니다!

답변

0

문제가 해결되었습니다.

실제로 내 경로가 Express으로 지정되었으며 rethinkdb과 관련이 없습니다.