Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neted objectContent greater than 1 #89

Closed
galinrustem opened this issue May 26, 2022 · 1 comment
Closed

neted objectContent greater than 1 #89

galinrustem opened this issue May 26, 2022 · 1 comment

Comments

@galinrustem
Copy link

It is possible to make nested objects greater than 1, for example, by the parameter "objectContentCount"
so that according to this configuration

[{"database":"db",
"collection":"cd_card_tree",
"count":1,
"content":{
"id_cleint":{"type":"long","maxLong":999999999999},
"id_card":{"type":"object", "objectContentCount":2, "objectContent":{
"card_no":{"type":"long","maxLong":9999999999},
"card_date":{"type":"date"},
"transaction":{"type":"object", "objectContentCount":2, "objectContent":{
"tran_sum":{"type":"decimal"},
"tran_date":{"type":"date"}}
}
}
}
}
}]

to make it work, this is the result
[
{
"_id": ObjectId("5a934e000102030405000001"),
"id_cleint": NumberLong(863926077139),
"id_card":[{
"card_date": "2021-10-01",
"card_no": NumberLong(1539691641),
"transaction":[
{
"tran_date": "2022-03-11",
"tran_sum": 100.0
},
{
"tran_date": "2022-03-11",
"tran_sum": 200.0
}]
},
{
"card_date": "2021-11-21",
"card_no": NumberLong(4539691641),
"transaction":[
{
"tran_date": "2022-03-11",
"tran_sum": 100.0
},
{
"tran_date": "2022-03-11",
"tran_sum": 200.0
}]
}]
}
]

@feliixx
Copy link
Owner

feliixx commented May 27, 2022

you need to use an array generator for this:

[
  {
    "database": "db",
    "collection": "cd_card_tree",
    "count": 1,
    "content": {
      "id_client": {
        "type": "long",
        "maxLong": 999999999999
      },
      "id_card": {
        "type": "array",
        "minLength": 2,
        "maxLength": 2,
        "arrayContent": {
          "type": "object",
          "objectContent": {
            "card_no": {
              "type": "long",
              "maxLong": 9999999999
            },
            "card_date": {
              "type": "date"
            },
            "transaction": {
              "type": "array",
              "minLength": 2,
              "maxLength": 2,
              "arrayContent": {
                "type": "object",
                "objectContent": {
                  "tran_sum": {
                    "type": "decimal"
                  },
                  "tran_date": {
                    "type": "date"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
]

you can try it here: mongoplayground.net/p/NxMxni8rnKj

@feliixx feliixx closed this as completed Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants