How can I search for a property if I don’t know its name?

Asked

Viewed 43 times

0

In my database mongodb I am saving a document with the following structure:

{
    "_id": "A/B",
    "Properties": {
        "Abandoned": {
            "TypeName": "int",
            "Name": "A/B/Abandoned",
            "Value": 2
        },
        "Busy": {
            "TypeName": "byte[]",
            "Name": "A/B/Busy",
            "Value": "<bynarydata>"
        }
    }
}

The properties do not have a known name and so I can not navigate through them, I mean, I can not use Properties.Abandoned (for example)

I’d like to get all the properties TypeName not be byte[]. There’s a way to do it?

To clarify: In the document I gave as an example I wanted to get only the property Abandoned.

  • I accept solutions with a slightly different scheme. As long as the change is explained.

1 answer

0


Looks like I’m gonna solve the problem by getting the properties byte[] in a different area of the document. This way I can make a simple projection to obtain only the non-binary properties. The document is structured as follows::

{
    "_id": "A/B",
    "Properties": {
        "Abandoned": {
            "TypeName": "int",
            "Name": "A/B/Abandoned",
            "Value": 2
        }
    },
    "ByteProperties": {
        "Busy" : {
            "TypeName": "byte[]",
            "Name": "A/B/Busy",
            "Value": "<bynarydata>"
        }
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.