Skip to main content

File

How to locate the record to which the file is attached by file name in a worksheet?

Take the filename saved in the object store as example bR2HbXfudAfo9JafdveE4K0C9J2g519Gae3d4I84820k8a9Bee3t5I914q5J4p6e.pdf

Go to MongoDB's mdattachment to query the corresponding docid.

> use mdattachment
> db.attachment.find({"name": "52a9dF0c71fscg6P9Lahfc5B41d4c0dv5FasdM5a5LaQdoaE9V1x64aK04en3Ydu.pdf"}).pretty()
{
"_id" : ObjectId("6413d880840db440e5f5a7be"),
"docid" : "a234f6ca-6bf2-4491-9261-e24758376b91",
"fid" : "a234f6ca-6bf2-4491-9261-e24758376b91",
"server" : "https://hap.domain.com/file/mdoc/",
"oFilename" : "APaaS测试文件",
"path" : "doc/20230317/",
"name" : "52a9dF0c71fscg6P9Lahfc5B41d4c0dv5FasdM5a5LaQdoaE9V1x64aK04en3Ydu.pdf",
......
}
  • Get the docid: a234f6ca-6bf2-4491-9261-e24758376b91

  • The oFilename here is also the actual name of the file saved in the record of the worksheet.

Query the control ID in the relationship table by docid.

> db.attachmentrelation.find({"docid" : "a234f6ca-6bf2-4491-9261-e24758376b91"}).pretty()
{
"_id" : ObjectId("6448eb672d71e11d04aae297"),
"docid" : "a234f6ca-6bf2-4491-9261-e24758376b91",
"fid" : "a234f6ca-6bf2-4491-9261-e24758376b91",
"fType" : 9,
"pids" : [
"eaf823e5-4205-44fd-8521-109d3ec29a92"
],
"ctime" : ISODate("2023-04-26T09:14:15.289Z"),
"sourceid" : "bac739dc-9f8f-4ea5-a1f8-bdea56d27b81",
"commentid" : "6448eb5c12053cf665be2131"
}
  • If fType = 9,then commentid is the control id,sourceid is the record id.
  • The control id obtained commentid is 6448eb5c12053cf665be2131
  • The record id obtained sourceid is bac739dc-9f8f-4ea5-a1f8-bdea56d27b81
    • sourceid corresponds to rowid of the corresponding worksheet in mdwsrows.
    • commentid corresponds to cid in the wscontrols in mdworksheet.

Query worksheet ID by commentid in wscontrols of mdworksheet.

> use mdworksheet
switched to db mdworksheet
> db.wscontrols.find({cid:"6448eb5c12053cf665be2131"}).pretty()
{
"_id" : ObjectId("6448eb5c12053cf665be2136"),
"cid" : "6448eb5c12053cf665be2131",
"wsid" : "6448eb5c12053cf665be212e",
......
}
  • wsid corresponds to the worksheet id. So the worksheet id obtained is 6448eb5c12053cf665be212e

Visit the following in your browser: System address/worksheet/worksheet ID, to access the worksheet where the queried file is attached.

Visit the following in your browser: System address/worksheet/worksheet ID/row/record ID, to access the record where the queried file is attached.