3

I'm using Artifactory 3.5. My artifacts have custom properties. I want to be able to query for all artifacts that have that property and I want the result to show the property and its value. I know I can use:

items.find(...).include("property.*")

However, this returns all properties for the item matching the find criteria. How can I display only the specific property that I want?

Dror Bereznitsky
  • 20,048
  • 3
  • 48
  • 57
George
  • 170
  • 2
  • 13

2 Answers2

4

The include element allows you to include only specific properties in the results

For example, the following query results will only include the artifact name and the "artifactory.licenses" property:

items.find({"@artifactory.licenses" : {"$eq" : "MIT"}}).include("name", "@artifactory.licenses")

This will return for example:

{
"results" : [ {
  "name" : "connection_pool-2.2.0.gem",
  "properties" : [ {
    "key" : "artifactory.licenses",
    "value" : "MIT"
  } ]}
}
Dror Bereznitsky
  • 20,048
  • 3
  • 48
  • 57
  • 1
    This answers my follow up as well. Wildcards do work! For example: item.find(...).include("name", "@*propertyKey*"). – George Apr 21 '16 at 20:39
0

Add "@*" in the include statement will get all properties.

For example:


items.find({
"$and":
[
{"created" : {"$gte":"2022-06-01"}}
]
}).include("name","repo","modified","@*").limit(10)
Qing Wang
  • 1
  • 1