Skip to content

Instantly share code, notes, and snippets.

@agarciadom
Last active October 7, 2015 11:42
Show Gist options
  • Save agarciadom/8081d31869a0b1de53b6 to your computer and use it in GitHub Desktop.
Save agarciadom/8081d31869a0b1de53b6 to your computer and use it in GitHub Desktop.
Example queries for Hawk - IncQuery integration
// Number of an instances of a type
return %s.all.size;
// Instances of a type
return %s.all;
// Get the number of instances of an EDataType (unseeded) //////////////////////////
var dataType = '%s';
var count = 0;
for (type in Model.types) {
var attrs = type.attributes.select(a|a.type=dataType);
if (not attrs.isEmpty) {
for (instance in type.all) {
for (attr in attrs) {
if (instance.getProperty(attr).isDefined()) {
count++;
}
}
}
}
}
return count;
// Contains version for the seeded case in EDataType
var dataType = '%s';
for (type in Model.types) {
var attrs = type.attributes.select(a|a.type=dataType);
if (not attrs.isEmpty) {
for (instance in type.all) {
for (attr in attrs) {
var value = instance.getProperty(attr) + '';
if (value = '%s') {
return 1;
}
}
}
}
}
return 0;
// Get the instances of an EDataType //////////////////////////
var dataType = '%s';
var values = Sequence {};
for (type in Model.types) {
var attrs = type.attributes.select(a|a.type=dataType);
if (not attrs.isEmpty) {
for (instance in type.all) {
for (attr in attrs) {
var value = instance.getProperty(attr);
if (value.isDefined()) {
values.add(value);
}
}
}
}
}
return values;
// Return all values of a specific attribute/reference
// (implicit foreach in EOL, implicit flatten in Thrift API)
return %s.all.%s;
//
return %s.all.contains(i | Model.getGraphNodeId(i)='%s');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment