Drush EFQ
Categories
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Downloads
Component created
Component changed
Component body
This is a simple drush plugin that adds the ability to perform a basic EntityFieldQuery (EFQ). This is useful when querying for counts or getting fully built entity data out of drupal as part of command-line scripts like bash. This allows you to pipe values out of drupal via drush, some basic examples are included below:
Examples:drush efq node page -- load all page nodes and print them to the screendrush efq node article --format=json -- print all article nodes as jsondrush efq user user --format=json -- print all users as jsondrush efq user user --count -- return a count of how many users are in the current sitedrush efq user user '[]' student --count -- return how many users have role student (special case in querying for users by role)
You can also pass in more advanced EFQ arguments as a 3rd optional argument but this needs to be in json format. Here are some examples from ELMSLN
# all the students in all the courses
d @courses-all efq user user '[]' student --count --y
# all of the courses that are being publicly marketed
d @online efq node course '[{"condition":"fieldCondition","arguments":["field_display_in_course_list","value","1","="]}]' --count
# number of service_instances that are for the "course" service
d @online efq node service_instance '[{"condition":"propertyCondition","arguments":[ "title","%courses","LIKE"]}]' --count --format=json
This would apply the additional conditions and pass the appropriate arguments to it.
