logicblox - How to create autonumbered predicates in .logic files in LogiQL? -
i trying set project autonumbered predicates. couldn't use lang:autonumbered option in .logic files gave me error expected constraint or lang:ordered.
so rewrote code in .lb file, worked. code follows:
create --unique addblock <doc> node(n), node_id(n:id) -> int(id). lang:autonumbered(`node_id). cons_node[] = n -> node(n). lang:constructor(`cons_node). node_has_label[l] = n -> string(l), node(n). node_attribute[n, k] = v -> node(n), string(k), string(v). node_attribute_id(id, att, val) <- node_id(n: id), node_attribute[n, att] = val. </doc> exec <doc> +node(n), +cons_node[] = n, +node_attribute[n, "label"] = "person", +node_attribute[n, "name"] = "alice". </doc> echo --- node_att_table: print node_attribute_id close --destroy now want move node.logic , separate data file. how do while keeping lang:autonumbered , lang:constructor commands?
edit:
this code have tried run:
block(`node) { export(`{ node(n), node_id(n:id) -> int(id). lang:autonumbered(`node_id). cons_node[] = n -> node(n). lang:constructor(`cons_node). node_attribute(n, k; v) -> node(n), string(k), string(v). }) } <-- . and error
error parsing block: expected constraint or lang:ordering pragma (error block_parse) on lang:autonumbered , lang:constructor lines when run lb config && make.
extra info: use vagrant run logicblox , basing examples on these blogs: https://developer.logicblox.com/2014/01/structuring-and-compiling-logicblox-applications/
i'm not sure original problem was, should work fine :). should able put logic in .logic file , use addblock --file option. same applies exec logic. using tags versus separate files equivalent. should identical including inline did there. if want load data csv file, should work: https://developer.logicblox.com/content/docs4/core-reference/webhelp/predicates.html#file-predicates
maybe earlier tried command-line , back-tick caused issues due special meaning in shell?
Comments
Post a Comment