Just when I thought that I was understanding, I ran into a problem that I have isolated into the following code snippet:
(() => {
const dt = Application('DEVONthink');
const db = dt.currentDatabase;
// get all tags in db
const myParents = db.parents.whose({_match:
[ObjectSpecifier().tagType, "ordinary tag"]});
console.log(`tags: ${myParents.length}`); // 1568
const pNames = myParents.name(); // 1 AppleEvent
const pUuids = myParents.uuid(); // 1 AppleEvent
const pTagTypes = myParents.tagType(); // 1 AppleEvent
const pRecordTypes = myParents.recordType(); // 1 AppleEvent
console.log(`myParents (all tags): ${pNames.length}`);
console.log(`myParents (${pNames.length}): ${pNames}`);
let badRecordList = [];
pTagTypes.forEach((tagType, index) => {
if (tagType !== 'ordinary tag') {
badRecordList.push({
name: pNames[index],
uuid: pUuids[index],
recordType: pRecordTypes[index],
tagType: pTagTypes[index]
});
}
});
console.log(`captured ${badRecordList.length} bad records - they aren't tags!`); // 446
console.log(JSON.stringify(badRecordList, null, 4)); // all {group, 'no tag'}
})()
Most of it is scaffolding to capture the error. The key line is:
// get all tags in db
const myParents = db.parents.whose({_match:
[ObjectSpecifier().tagType, "ordinary tag"]});
I expected that this code would return all tag groups in 1 Apple Event.
I have three “production” databases, and this code works as expected in 2 of the 3. However in the third, this code returns the tag groups - but a slew of other groups as well.
The console output is:
tags: 1568
myParents (all tags): 1568
myParents (1568): veh-USMC Trailer,DMV,doc-Title,doc-Registration,summaryNote,.pmf,pmf,showNumbers,Ahmet Kazan - Handicraftlamps,Arctic Scandinavia map & Travel Tips from Discover the World,
...
August/September 2017,Flights: LAX-SEA-KTN August 7-12, 2018
captured 446 bad records - they aren't tags!
[
{
"name": "Ahmet Kazan - Handicraftlamps",
"uuid": "9240BC99-3CDD-4EA0-AF54-EA6FDD878B56",
"recordType": "group",
"tagType": "no tag"
},
{
"name": "Arctic Scandinavia map & Travel Tips from Discover the World",
"uuid": "690D9780-7881-49BB-9345-5EDB9C8A102F",
"recordType": "group",
"tagType": "no tag"
},
{
"name": "Abisko Boutique - Swedish Sports Clothing & Gloves",
"uuid": "7F29ABDD-F8A4-4D96-9BEA-613F5C05ABA4",
"recordType": "group",
"tagType": "no tag"
},
...
"name": "Flights: LAX-SEA-KTN August 7-12, 2018",
"uuid": "072BD863-9F38-4B23-A729-99995F86ECCD",
"recordType": "group",
"tagType": "no tag"
}
]
So, there are 446 regular groups that get caught up in the net. They are all {group, no tag}, so I don’t understand. I don’t (intentionally) use groups for tagging and I would have expected these to show as {group, group tag} in any case. Clearly I have a data dependent problem, so it may be hard for anyone else to reproduce.
The good news is that it is blazingly fast for producing hierarchical tag listings in the databases where it does work.
Any ideas @chrillek or @cgrunenberg ?

