如何使用REST API在MongoDB中找到Not Null值?

时间:2014-09-24 07:37:50

标签: mongodb sleepy-mongoose

这是网址 http://ec2-54-84-170-46.compute-1.amazonaws.com:27080/quickrx/Assessment/_find

,结果是

{
    "ok": 1,
    "results": [
        {
            "bloodpressure": "80/120",
            "weight": 70,
            "customParams": [],
            "sugar": {
                "sugarF": 120
            },
            "patientId": "6048d4a5-8d92-45d1-8c2d-630ed468ffc6",
            "pulse": 60,
            "height": 160,
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "",
            "personalHistory": "",
            "date": {
                "$date": 1402669208931
            },
            "_id": "827f0520-3e22-4c4c-ba5b-fe9dbdbff33b",
            "type": "Assessment"
        },
        {
            "customParams": [],
            "patientId": "eac86b15-367a-447d-951a-d59521a009c8",
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "ESSENTIAL HYPERTENSION",
            "personalHistory": "",
            "date": {
                "$date": 1404728670779
            },
            "_id": "34b487bd-d33e-42a3-830d-c8996cca24b2",
            "type": "Assessment"
        },
        {
            "customParams": [],
            "patientId": "278fd898-849c-4723-a2ee-3ed506d9124b",
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "",
            "personalHistory": "",
            "date": {
                "$date": 1404979348282
            },
            "_id": "f2f1d94b-6c7a-4fa5-8a77-e2f324bd5426",
            "type": "Assessment"
        },
        {
            "customParams": [],
            "patientId": "eac86b15-367a-447d-951a-d59521a009c8",
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "",
            "personalHistory": "",
            "date": {
                "$date": 1404558930564
            },
            "_id": "47ea4013-424e-46fc-b2a7-bc861c47d434",
            "type": "Assessment"
        },
        {
            "customParams": [],
            "patientId": "eac86b15-367a-447d-951a-d59521a009c8",
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "ACID PEPTIC DISEASE",
            "personalHistory": "",
            "date": {
                "$date": 0
            },
            "_id": "d7d175dc-2aad-492e-ab59-5cdc272c2c9d",
            "type": "Assessment"
        },
        {
            "bloodpressure": "180/90",
            "weight": 73,
            "customParams": [
                {
                    "unit": "",
                    "value": "mad",
                    "key": "sad"
                }
            ],
            "sugar": {
                "sugarR": 102,
                "sugarPP": 85,
                "sugarF": 45
            },
            "patientId": "604d6e2f-12e0-4fe2-91ad-4991832d92ee",
            "pulse": 94,
            "height": 175,
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "",
            "personalHistory": "",
            "date": {
                "$date": 1404915035764
            },
            "_id": "fcc9a621-9588-48a1-9563-80cb7a526fb6",
            "type": "Assessment"
        },
        {
            "customParams": [],
            "patientId": "278fd898-849c-4723-a2ee-3ed506d9124b",
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "",
            "personalHistory": "",
            "date": {
                "$date": 1404979343801
            },
            "_id": "d11ed9db-0176-4c00-9dc5-01610ffcde3e",
            "type": "Assessment"
        },
        {
            "bloodpressure": "456/456",
            "weight": 435,
            "customParams": [
                {
                    "unit": "C",
                    "value": "30",
                    "key": "temp"
                }
            ],
            "sugar": {
                "sugarR": 6456,
                "sugarPP": 5645,
                "sugarF": 4564
            },
            "clinicalNotes": "",
            "patientId": "278fd898-849c-4723-a2ee-3ed506d9124b",
            "pulse": 456,
            "height": 546,
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "",
            "personalHistory": "",
            "date": {
                "$date": 1404979388678
            },
            "_id": "c8c5c5f6-737e-4b04-ae7b-0fd31f796a9a",
            "type": "Assessment"
        },
        {
            "bloodpressure": "645/645",
            "weight": 654,
            "customParams": [
                {
                    "unit": "°C",
                    "value": "35",
                    "key": "Temperature"
                },
                {
                    "unit": "",
                    "value": "45",
                    "key": "Peak Flow"
                },
                {
                    "unit": "",
                    "value": "1,4,18",
                    "key": "Dental Screening"
                },
                {
                    "unit": "",
                    "value": "1.7",
                    "key": "Vision Test"
                }
            ],
            "sugar": {
                "sugarR": 5645,
                "sugarPP": 5464,
                "sugarF": 6456
            },
            "clinicalNotes": "",
            "patientId": "278fd898-849c-4723-a2ee-3ed506d9124b",
            "pulse": 645,
            "height": 645,
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "",
            "personalHistory": "",
            "date": {
                "$date": 1404980860781
            },
            "_id": "488024bf-d5c9-4650-af93-366cc84d29b3",
            "type": "Assessment"
        },
        {
            "bloodpressure": "645/645",
            "weight": 654,
            "customParams": [
                {
                    "unit": "°C",
                    "value": "35",
                    "key": "Temperature"
                },
                {
                    "unit": "",
                    "value": "45",
                    "key": "Peak Flow"
                },
                {
                    "unit": "",
                    "value": "1,4,18",
                    "key": "Dental Screening"
                },
                {
                    "unit": "",
                    "value": "1.7",
                    "key": "Vision Test"
                }
            ],
            "sugar": {
                "sugarR": 5645,
                "sugarPP": 5464,
                "sugarF": 6456
            },
            "clinicalNotes": "",
            "patientId": "278fd898-849c-4723-a2ee-3ed506d9124b",
            "pulse": 645,
            "height": 645,
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "",
            "personalHistory": "",
            "date": {
                "$date": 1404980868329
            },
            "_id": "05c7c3b9-1255-4189-b6b0-d4b25d6a6aff",
            "type": "Assessment"
        },
        {
            "bloodpressure": "456/456",
            "weight": 456,
            "customParams": [
                {
                    "unit": "°C",
                    "value": "56",
                    "key": "Temperature"
                },
                {
                    "unit": "",
                    "value": "565",
                    "key": "Peak Flow"
                },
                {
                    "unit": "",
                    "value": "1, 4, 8, 15, 31",
                    "key": "Dental Screening"
                },
                {
                    "unit": "",
                    "value": "1.4",
                    "key": "Vision Test"
                },
                {
                    "unit": "%",
                    "value": "80",
                    "key": "Pulse Oximeter"
                }
            ],
            "sugar": {
                "sugarR": 6455,
                "sugarPP": 4645,
                "sugarF": 4565
            },
            "patientId": "278fd898-849c-4723-a2ee-3ed506d9124b",
            "pulse": 546,
            "height": 546,
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "",
            "personalHistory": "",
            "date": {
                "$date": 1404983214043
            },
            "_id": "607b5420-e167-4723-9135-e3c4fe7fff70",
            "type": "Assessment"
        },
        {
            "bloodpressure": "434/343",
            "weight": 343,
            "customParams": [
                {
                    "unit": "°C",
                    "value": "43",
                    "key": "Temperature"
                },
                {
                    "unit": "",
                    "value": "54",
                    "key": "Peak Flow"
                },
                {
                    "unit": "",
                    "value": "67",
                    "key": "Dental Screening"
                },
                {
                    "unit": "",
                    "value": "23",
                    "key": "Vision Test"
                },
                {
                    "unit": "%",
                    "value": "45",
                    "key": "Pulse Oximeter"
                },
                {
                    "unit": "BPM",
                    "value": "877",
                    "key": "Pulse"
                }
            ],
            "sugar": {
                "sugarR": 3545,
                "sugarPP": 3454,
                "sugarF": 4435
            },
            "patientId": "26517fac-52f3-4477-ad6a-b42af2d0a882",
            "pulse": 343,
            "height": 434,
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "ACID PEPTIC DISEASE",
            "personalHistory": "",
            "date": {
                "$date": 1405008241219
            },
            "_id": "2ecba67a-f27a-46f1-849f-8013fa57d1af",
            "type": "Assessment"
        },
        {
            "customParams": [
                {
                    "unit": "°C",
                    "value": "",
                    "key": "Temperature"
                },
                {
                    "unit": "",
                    "value": "",
                    "key": "Peak Flow"
                },
                {
                    "unit": "",
                    "value": "",
                    "key": "Dental Screening"
                },
                {
                    "unit": "",
                    "value": "",
                    "key": "Vision Test"
                },
                {
                    "unit": "%",
                    "value": "",
                    "key": "Pulse Oximeter"
                },
                {
                    "unit": "BPM",
                    "value": "",
                    "key": "Pulse"
                }
            ],
            "patientId": "ffd10522-13e8-44df-ae2c-adbffa1786ee",
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "VENTRUCULAR TACHYCARDIATORSADES DE POINTES",
            "personalHistory": "",
            "date": {
                "$date": 1405011015921
            },
            "_id": "ce3bc05a-be01-43ba-8f8f-355e4edcf4a4",
            "type": "Assessment"
        },
        {
            "customParams": [
                {
                    "unit": "°C",
                    "value": "",
                    "key": "Temperature"
                },
                {
                    "unit": "",
                    "value": "",
                    "key": "Peak Flow"
                },
                {
                    "unit": "",
                    "value": "",
                    "key": "Dental Screening"
                },
                {
                    "unit": "",
                    "value": "",
                    "key": "Vision Test"
                },
                {
                    "unit": "%",
                    "value": "",
                    "key": "Pulse Oximeter"
                },
                {
                    "unit": "BPM",
                    "value": "",
                    "key": "Pulse"
                }
            ],
            "patientId": "ffd10522-13e8-44df-ae2c-adbffa1786ee",
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "VSD WITH ASD",
            "personalHistory": "",
            "date": {
                "$date": 1405017842035
            },
            "_id": "ce1a7d01-e8ab-4e09-bf9b-4dbaf6caadd5",
            "type": "Assessment"
        },
        {
            "customParams": [
                {
                    "unit": "°C",
                    "value": "",
                    "key": "Temperature"
                },
                {
                    "unit": "",
                    "value": "",
                    "key": "Peak Flow"
                },
                {
                    "unit": "",
                    "value": "",
                    "key": "Dental Screening"
                },
                {
                    "unit": "",
                    "value": "",
                    "key": "Vision Test"
                },
                {
                    "unit": "%",
                    "value": "",
                    "key": "Pulse Oximeter"
                },
                {
                    "unit": "BPM",
                    "value": "",
                    "key": "Pulse"
                }
            ],
            "patientId": "1087c1a3-6793-4d6f-bdb3-f4a1bf040c94",
            "doctorId": "2270f71b-34fd-49bb-874c-fd8bb552106c",
            "diagnosis": "",
            "personalHistory": "",
            "date": {
                "$date": 1405066132237
            },
            "_id": "8b628cad-fcc4-4034-9feb-bbdf313f59e4",
            "type": "Assessment"
        }
    ],
    "id": 1360
}

在这个结果中,我只想要那些具有某个值的诊断字段不是空的值。

1 个答案:

答案 0 :(得分:0)

在Sleepy Mongoose上,您可以使用正则表达式来过滤查询结果,因此要匹配diagnosis字段不是空字符串的模型,请将以下条件附加到URL的末尾:

criteria={"diagnosis":{"$regex":".+"}}

正则表达式(/.+/)将测试任何至少包含一个字符的字符串(包括空格!)。

附加的编码请求如下所示:

curl -X GET 'http://ec2-54-84-170-46.compute-1.amazonaws.com:27080/quickrx/Assessment/_find?criteria=%7B%22diagnosis%22:%7B%22$regex%22:%22.+%22%7D%7D'

在这里,为了便于阅读,它已被解码:

curl -X GET 'http://ec2-54-84-170-46.compute-1.amazonaws.com:27080/quickrx/Assessment/_find?criteria={"diagnosis":{"$regex":".+"}}'

参考