H5W3
当前位置:H5W3 > 其他技术问题 > 正文

mongodb中有查询子集的名称等于xx的语句吗?

表结构:

    "id":"xxxx",
    "xxx":"xxx",
    "catalogs" : [
        {
            "catalog_number" : "4.1",
            "catalog_name" : "信访受理审查案件",
            "subcatalogs" : [
                {
                    "subcatalogs_number" : "4.1.1",
                    "subcatalogs_name" : "受理情况",
                    "subcatalog" : [
                        {
                            "chinese_name" : "信访类别",
                            "internal_identifier" : "DE02.07.001",
                            "version" : "v1.0",
                            "definition" : "信访人提供信访案件的类别。",
                            "data_type" : "字符型",
                            "data_format" : "a..30",
                            "range" : "DZJW 2203.7-2017中CC02.07.001。",
                            "synonymous_nouns" : "",
                            "measuring_unit" : "",
                            "remarks" : ""
                        },
                        {
                            "chinese_name" : "信访类别代码",
                            "internal_identifier" : "DE02.07.002",
                            "version" : "v1.0",
                            "definition" : "信访人提供信访案件类别的代码。",
                            "data_type" : "字符型",
                            "data_format" : "n1",
                            "range" : "DZJW 2203.7-2017中CC02.07.001。",
                            "synonymous_nouns" : "",
                            "measuring_unit" : "",
                            "remarks" : ""
                        },
                        {
                            "chinese_name" : "信访类别2",
                            "internal_identifier" : "DE02.07.001",
                            "version" : "v1.0",
                            "definition" : "信访人提供信访案件的类别。",
                            "data_type" : "字符型",
                            "data_format" : "a..30",
                            "range" : "DZJW 2203.7-2017中CC02.07.001。",
                            "synonymous_nouns" : "",
                            "measuring_unit" : "",
                            "remarks" : ""
                        },
                        {
                            "chinese_name" : "信访类别代码2",
                            "internal_identifier" : "DE02.07.002",
                            "version" : "v1.0",
                            "definition" : "信访人提供信访案件类别的代码。",
                            "data_type" : "字符型",
                            "data_format" : "n1",
                            "range" : "DZJW 2203.7-2017中CC02.07.001。",
                            "synonymous_nouns" : "",
                            "measuring_unit" : "",
                            "remarks" : ""
                        }
                    ]
                },
                {
                    "subcatalogs_number" : "4.1.2",
                    "subcatalogs_name" : "受理情况2",
                    "subcatalog" : [
                        {
                            "chinese_name" : "信访类别22",
                            "internal_identifier" : "DE02.07.001",
                            "version" : "v1.0",
                            "definition" : "信访人提供信访案件的类别。",
                            "data_type" : "字符型",
                            "data_format" : "a..30",
                            "range" : "DZJW 2203.7-2017中CC02.07.001。",
                            "synonymous_nouns" : "",
                            "measuring_unit" : "",
                            "remarks" : ""
                        },
                        {
                            "chinese_name" : "信访类别代码22",
                            "internal_identifier" : "DE02.07.002",
                            "version" : "v1.0",
                            "definition" : "信访人提供信访案件类别的代码。",
                            "data_type" : "字符型",
                            "data_format" : "n1",
                            "range" : "DZJW 2203.7-2017中CC02.07.001。",
                            "synonymous_nouns" : "",
                            "measuring_unit" : "",
                            "remarks" : ""
                        },
                        {
                            "chinese_name" : "信访类别222",
                            "internal_identifier" : "DE02.07.001",
                            "version" : "v1.0",
                            "definition" : "信访人提供信访案件的类别。",
                            "data_type" : "字符型",
                            "data_format" : "a..30",
                            "range" : "DZJW 2203.7-2017中CC02.07.001。",
                            "synonymous_nouns" : "",
                            "measuring_unit" : "",
                            "remarks" : ""
                        },
                        {
                            "chinese_name" : "信访类别代码222",
                            "internal_identifier" : "DE02.07.002",
                            "version" : "v1.0",
                            "definition" : "信访人提供信访案件类别的代码。",
                            "data_type" : "字符型",
                            "data_format" : "n1",
                            "range" : "DZJW 2203.7-2017中CC02.07.001。",
                            "synonymous_nouns" : "",
                            "measuring_unit" : "",
                            "remarks" : ""
                        }
                    ]
                }
            ]
        },
        {
            "catalog_number" : "4.2",
            "catalog_name" : "举报类信访案件",
            "subcatalogs" : [
                {
                    "chinese_name" : "奖励日期2",
                    "internal_identifier" : "DE02.07.094",
                    "version" : "v1.0",
                    "definition" : "举报线索经查证属实,提起公诉后被法院做出有罪生效判决的,本院给予举报人一定物质奖励的具体时间。",
                    "data_type" : "日期型",
                    "data_format" : "YYYYMMDD",
                    "range" : "",
                    "synonymous_nouns" : "",
                    "measuring_unit" : "",
                    "remarks" : "DZJW 2102.4-2017中DE01.04.01。"
                },
                {
                    "chinese_name" : "奖励日期22",
                    "internal_identifier" : "DE02.07.094",
                    "version" : "v1.0",
                    "definition" : "举报线索经查证属实,提起公诉后被法院做出有罪生效判决的,本院给予举报人一定物质奖励的具体时间。",
                    "data_type" : "日期型",
                    "data_format" : "YYYYMMDD",
                    "range" : "",
                    "synonymous_nouns" : "",
                    "measuring_unit" : "",
                    "remarks" : "DZJW 2102.4-2017中DE01.04.01。"
                },
                {
                    "chinese_name" : "奖励日期222",
                    "internal_identifier" : "DE02.07.094",
                    "version" : "v1.0",
                    "definition" : "举报线索经查证属实,提起公诉后被法院做出有罪生效判决的,本院给予举报人一定物质奖励的具体时间。",
                    "data_type" : "日期型",
                    "data_format" : "YYYYMMDD",
                    "range" : "",
                    "synonymous_nouns" : "",
                    "measuring_unit" : "",
                    "remarks" : "DZJW 2102.4-2017中DE01.04.01。"
                }
            ]
        },
        {
            "catalog_number" : "4.3",
            "catalog_name" : "举报类信访案件3",
            "subcatalogs" : [
                {
                    "chinese_name" : "奖励日期33",
                    "internal_identifier" : "DE02.07.094",
                    "version" : "v1.0",
                    "definition" : "举报线索经查证属实,提起公诉后被法院做出有罪生效判决的,本院给予举报人一定物质奖励的具体时间。",
                    "data_type" : "日期型",
                    "data_format" : "YYYYMMDD",
                    "range" : "",
                    "synonymous_nouns" : "",
                    "measuring_unit" : "",
                    "remarks" : "DZJW 2102.4-2017中DE01.04.01。"
                }
            ]
        }
    ],
    "current_version" : "20180410-v1.03",

问题一:我想取”catalogs.catalog_name” 为 “举报类信访案件”中的第二条到第四条的信息,sql该怎么写?
问题二:想要修改且只修改”catalogs.catalog_name” 为 “举报类信访案件”中的第一条信息,
sql该怎么写
试了很多办法,主要是这整个json本身就是一条数据。这样的操作是不是做不到?
感谢大家解答,非常感谢!

本文地址:H5W3 » mongodb中有查询子集的名称等于xx的语句吗?

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址