How to retrieve the name of a document from the Alfresco database (PostgreSQL)? I'm trying to get a list of documents created by a given user, e.g. admin, from a starting date, e.g. 2015-05-03:
SELECT child.child_node_name, node.audit_created
FROM alf_child_assoc child, alf_node node, alf_node_properties prop, alf_qname qname
WHERE child.child_node_id = node.id
AND node.id = prop.node_id
AND prop.qname_id = qname.id
AND qname.local_name = 'content'
AND node.audit_creator = 'admin'
AND node.audit_created > '2015-05-03'
ORDER BY node.audit_created
How do I get actual documents and not all content items? Because now it also displays full node references and I just want the human readable name of a document. Any suggestions?
By the way, I'm working on the back-end (Repository), not on Share. And I'm using Alfresco 5.0.1.
Based on the other anwsers I created this query:
This way you don't have to know the qname_id.
Thank you Sam, Gagravarr and streetturtle.
Updated
So here is SQL you need to use, this one for
cm:content
type:It will return human readable document name, username of creator and date when this document was created.
And if you have some custom type of document, let's say
ep:content
with namespacehttp://www.mycomp.com/model/epersonnel/1.0
this query will do the work:In Alfresco, the name of a document is a property of of type
cm:name
/http://www.alfresco.org/model/content/1.0:name
So, first up, find the ID of that qname. It may vary between Alfresco installs, depending on the order things got added during setup, but it will be constant for an Alfresco repository. Query is:
Now, search for documents by name, using the ID from there:
That will give you all the node UUIDs (main part of the noderef) along with their names.
Add more node filters as required!
I ran this SQL script to find the equivalent qname id for this property
I got 2 rows with id 21 and 29 but figured out the interesting one is 29.
You will get name for any node not only files.
You can find useful queries http://streetturtle.ninja/2015/05/01/usefule-alfresco-queries/
Hope this help
Good luck, Sam