edit-icon download-icon

Does ApsaraDB for MongoDB support nesting?

Last Updated: Jan 29, 2018

ApsaraDB for MongoDB supports nesting. For example:

  1. {
  2. _id:ObjectId(“569ddc41f91e4b4747b5cb7b”),
  3. id:”16399864”,
  4. timestamp:”1453185620”,
  5. tablename:”houseinfo”,
  6. dbname:”corp_officebuilding”,
  7. primaryKeys:”Id”,
  8. class:”class com.uban.dts.bean.DtsLog”,
  9. dbType:”MYSQL”,
  10. fieldCount:”138”,
  11. opt:”UPDATE”,
  12. fields:{“Status”:{“dest”:”0”,”orgi”:”1420041600”}}
  13. }

A nested document is defined in fields:{“Status”:{“dest”:”0”,”orgi”:”1420041600”}}.

Query example:

  1. db.a.find({'opt' : "UPDATE",'fields.Status':{$exists:true}})

Query results:

查询结果

Note:

When you save nested data, this line indicates nesting fields:{“Status”:{“dest”:”0”,”orgi”:”1420041600”}}

If this line is used fields:”{“Status”:{“dest”:”0”,”orgi”:”1420041600”}}”, the quotation marks are used to define the fields string instead of nesting.

Thank you! We've received your feedback.