only the last subdocument is shown if they have the same filed name

Josef Klug shared this problem 5 years ago
Not a Problem

example :

original document:

"m_result" : { "_class_id_optional" : 14,

"_tracking" : false,

"_version" : { "$numberLong" : "0" },

"count" : { "$numberLong" : "9" },

"item_version" : { "$numberLong" : "0" },

"item" : { "_class_id_optional" : 15,

"_tracking" : false,

"_version" : { "$numberLong" : "0" },

"first" : "T",

"second" : 5 },

"item" : { "first" : "WIM_not_used",

"second" : 0 },

"item" : { "first" : "check_action_CS_offline",

"second" : 0 },

"item" : { "first" : "check_action_Door_opened",

"second" : 0 },

"item" : { "first" : "check_action_Enforcement_off",

"second" : 0 },

"item" : { "first" : "check_action_Station_degraded",

"second" : 0 },

"item" : { "first" : "check_action_Time_sync_external",

"second" : 0 },

"item" : { "first" : "check_action_Time_sync_internal",

"second" : 0 },

"item" : { "first" : "check_action_WAN_link_offline",

"second" : 0 } } },


shown in nosqlbooster:

"m_result" : {

"_class_id_optional" : 14,

"_tracking" : false,

"_version" : 0,

"count" : 9,

"item_version" : 0,

"item" : {

"first" : "check_action_WAN_link_offline",

"second" : 0

}

}

with this serious bug makes nosqlbooster currently not useable

Replies (1)

photo
1

Your code has a bug. Javascript does not allow multiple fields of the same object to have the same name. You need to put your items in an array field.

var obj = {
    "m_result": {
        "_class_id_optional": 14,

        "_tracking": false,

        "_version": { "$numberLong": "0" },

        "count": { "$numberLong": "9" },

        "item_version": { "$numberLong": "0" },

        items: [
            {
                "_class_id_optional": 15,

                "_tracking": false,

                "_version": { "$numberLong": "0" },

                "first": "T",

                "second": 5
            },

            {
                "first": "WIM_not_used",

                "second": 0
            }
            ...

        ]


    }
}}

Leave a Comment
 
Attach a file