File
How to locate the record to which the file is attached by file name in a worksheet?
- Query by file name saved in object store
- Query by file name when uploaded
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.
Take the name of the file when it is uploaded as example:
APaaS test file.pdf
.
Go to MongoDB's mdattachment
to query corresponding docid
.
> use mdattachment
# Exact query by file name
> db.attachment.find({"oFilename":"APaaS test file"}).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 test file",
"path" : "doc/20230317/",
"name" : "52a9dF0c71fscg6P9Lahfc5B41d4c0dv5FasdM5a5LaQdoaE9V1x64aK04en3Ydu.pdf",
......
}
# Fuzzy query by file name
> db.attachment.find({oFilename:{$regex:'.*PaaS.*'}}).pretty()
Get the
docid
:a234f6ca-6bf2-4491-9261-e24758376b91
The
name
here is also the name of the file saved in object store.
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
,thencommentid
is the control id,sourceid
is the record id. - The control id obtained
commentid
is6448eb5c12053cf665be2131
- The record id obtained
sourceid
isbac739dc-9f8f-4ea5-a1f8-bdea56d27b81
sourceid
corresponds torowid
of the corresponding worksheet inmdwsrows
.commentid
corresponds tocid
in thewscontrols
inmdworksheet
.
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 is6448eb5c12053cf665be212e
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.