flowquery 1.0.52 → 1.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,7 +30,7 @@ The combination of graph querying and pipeline processing makes FlowQuery ideal
30
30
  └──────────┘
31
31
  ```
32
32
 
33
- See the [Language Reference](#language-reference) and [Quick Cheat Sheet](#quick-cheat-sheet) for full syntax documentation.
33
+ See the [Language Reference](#language-reference) and [Quick Cheat Sheet](#quick-cheat-sheet) for full syntax documentation. For a complete worked example, see [Virtual Org Chart](#virtual-org-chart).
34
34
 
35
35
  FlowQuery is written in TypeScript and runs both in the browser and in Node.js as a self-contained single-file JavaScript library. A pure Python implementation of FlowQuery with full functional fidelity is also available in the [flowquery-py](./flowquery-py) sub-folder (`pip install flowquery`).
36
36
 
@@ -891,6 +891,92 @@ WITH f WHERE f.name = 'double'
891
891
  RETURN f.name AS name, f.description AS description, f.category AS category
892
892
  ```
893
893
 
894
+ ## Examples
895
+
896
+ ### Virtual Org Chart
897
+
898
+ This single multi-statement query creates a virtual graph for a fictitious company — complete with employees, skills, phone numbers, and a management chain — then queries it to produce an org chart. [Try live!](https://microsoft.github.io/FlowQuery/?rZXPbtNAEMbFhUMOReXAeW4OwkH521ZBQgolrVQlSogDQlRVtdjTeKm9a603Bavqw_AAPEVfDO16s_EmEVElfPHuzGf7N9-M7UN4BfX-MM0SXiC-hkEA9zUAgJdwqc_quKdRH1o-MJJiH7yACAKnMTLP1-kf_PucykSlTocTE6weEWZEyBSZ7IM3_IXhUtI71MIs5kxd-KbV6PV6jWar2fR8yG9pkuR9uPQCKYjEReH54I2QRCjymGZqd0YZYSF6Vw--C9q2oGMiwmUOM3qHgnh-FfTLFPgNDNmCMkRB2ULTuKBOchO03Ww5oAMRxlRiKJdCVeadJnwZqcUYmeT6JlukHUs6FbQgMCUSEw2yRToVPFqG0prrkLrJTdLOBumMkyglWVbW5Q0YSQpJw1xtPn_dpuxayguSYg4fBOe3Sl2lDJBRLqyhBuVJfrYdynmRYRAKmqmyvGkhY67mzTsXJIs_jbYxexZzRBl8i4np6f_G7LhmLnMNGBS5xFR7-BHvJlm-DXhkAQepeoMueMxyXVQF0LQSxoSRxW7Afd12fQxCsUw1FpEEdLNzqjkDSW4x5kmEAsaLVG4TH1viOU8ff-dwTkT4-Ids9p7fyJ9EoGvrk0ztuqYi0fVtDMEcc7nzPTqxnGdE0pTAIGkEpMDI9XYX55Moew7leibHI2vwlGaYUIaq_xrySn1SBYZcRHp_YDZvaaQyNPJXAVWCCqmzDa7wVWK1XlcPsNKt61DK9c7eSFejcnphw2U5Kl6uag_vaofuP6Fx2Z8Np5PZPLieT64a-_8WCd7Ia_MlFnQRl5tWtWtW0tkv6VYl7Z2S3n7JUVXS2Sk5rkq6OyUnruTfHTZXqbRZWttXN9GXmrWy_gXUce1v7RnUt_x_X08XoqI50A_FcnzWxyAANBrfKOwsWYVcjxNWR8ikK2NkNOUUVR9SjpNJm2mqpMtImU8XwqXUvmVcyHzOa88dBN9U9Bc)
899
+
900
+ ```cypher
901
+ CREATE VIRTUAL (:Employee) AS {
902
+ UNWIND [
903
+ {id: 1, name: 'Sara Chen', jobTitle: 'CEO', department: 'Executive', phone: '+1-555-0100', skills: ['Strategy', 'Leadership', 'Finance']},
904
+ {id: 2, name: 'Marcus Rivera', jobTitle: 'VP of Engineering', department: 'Engineering', phone: '+1-555-0201', skills: ['Architecture', 'Cloud', 'Mentoring']},
905
+ {id: 3, name: 'Priya Patel', jobTitle: 'VP of Product', department: 'Product', phone: '+1-555-0301', skills: ['Roadmapping', 'Analytics', 'UX']},
906
+ {id: 4, name: 'James Brooks', jobTitle: 'Senior Engineer', department: 'Engineering', phone: '+1-555-0202', skills: ['TypeScript', 'Python', 'GraphQL']},
907
+ {id: 5, name: 'Lin Zhang', jobTitle: 'Senior Engineer', department: 'Engineering', phone: '+1-555-0203', skills: ['Rust', 'Systems', 'DevOps']},
908
+ {id: 6, name: 'Amara Johnson', jobTitle: 'Product Manager', department: 'Product', phone: '+1-555-0302', skills: ['Scrum', 'Data Analysis', 'Stakeholder Mgmt']},
909
+ {id: 7, name: 'Tomás García', jobTitle: 'Software Engineer', department: 'Engineering', phone: '+1-555-0204', skills: ['React', 'TypeScript', 'Testing']},
910
+ {id: 8, name: 'Fatima Al-Sayed', jobTitle: 'Software Engineer', department: 'Engineering', phone: '+1-555-0205', skills: ['Python', 'ML', 'Data Pipelines']}
911
+ ] AS record
912
+ RETURN record.id AS id, record.name AS name, record.jobTitle AS jobTitle,
913
+ record.department AS department, record.phone AS phone, record.skills AS skills
914
+ };
915
+ CREATE VIRTUAL (:Employee)-[:REPORTS_TO]-(:Employee) AS {
916
+ UNWIND [
917
+ {left_id: 2, right_id: 1},
918
+ {left_id: 3, right_id: 1},
919
+ {left_id: 4, right_id: 2},
920
+ {left_id: 5, right_id: 2},
921
+ {left_id: 6, right_id: 3},
922
+ {left_id: 7, right_id: 4},
923
+ {left_id: 8, right_id: 4}
924
+ ] AS record
925
+ RETURN record.left_id AS left_id, record.right_id AS right_id
926
+ };
927
+ MATCH (e:Employee)
928
+ OPTIONAL MATCH (e)-[:REPORTS_TO]->(mgr:Employee)
929
+ RETURN
930
+ e.name AS employee,
931
+ e.jobTitle AS title,
932
+ e.department AS department,
933
+ e.phone AS phone,
934
+ e.skills AS skills,
935
+ mgr.name AS reportsTo
936
+ ORDER BY e.department, e.name
937
+ ```
938
+
939
+ Output:
940
+
941
+ | employee | title | department | phone | skills | reportsTo |
942
+ | --------------- | ----------------- | ----------- | ----------- | ---------------------------------------- | ------------- |
943
+ | Fatima Al-Sayed | Software Engineer | Engineering | +1-555-0205 | [Python, ML, Data Pipelines] | James Brooks |
944
+ | James Brooks | Senior Engineer | Engineering | +1-555-0202 | [TypeScript, Python, GraphQL] | Marcus Rivera |
945
+ | Lin Zhang | Senior Engineer | Engineering | +1-555-0203 | [Rust, Systems, DevOps] | Marcus Rivera |
946
+ | Marcus Rivera | VP of Engineering | Engineering | +1-555-0201 | [Architecture, Cloud, Mentoring] | Sara Chen |
947
+ | Tomás García | Software Engineer | Engineering | +1-555-0204 | [React, TypeScript, Testing] | James Brooks |
948
+ | Sara Chen | CEO | Executive | +1-555-0100 | [Strategy, Leadership, Finance] | null |
949
+ | Amara Johnson | Product Manager | Product | +1-555-0302 | [Scrum, Data Analysis, Stakeholder Mgmt] | Priya Patel |
950
+ | Priya Patel | VP of Product | Product | +1-555-0301 | [Roadmapping, Analytics, UX] | Sara Chen |
951
+
952
+ You can further explore the graph — for example, find the full management chain from any employee up to the CEO:
953
+
954
+ ```cypher
955
+ MATCH (e:Employee)-[:REPORTS_TO*1..]->(mgr:Employee)
956
+ WHERE e.name = 'Tomás García'
957
+ RETURN e.name AS employee, collect(mgr.name) AS managementChain
958
+ // [{ employee: "Tomás García", managementChain: ["James Brooks", "Marcus Rivera", "Sara Chen"] }]
959
+ ```
960
+
961
+ Or find each manager's direct reports:
962
+
963
+ ```cypher
964
+ MATCH (dr:Employee)-[:REPORTS_TO]->(mgr:Employee)
965
+ RETURN mgr.name AS manager, collect(dr.name) AS directReports
966
+ ORDER BY manager
967
+ ```
968
+
969
+ Or find all employees who share a skill:
970
+
971
+ ```cypher
972
+ MATCH (a:Employee), (b:Employee)
973
+ WHERE a.id < b.id
974
+ WITH a, b, [s IN a.skills WHERE s IN b.skills] AS shared
975
+ WHERE size(shared) > 0
976
+ RETURN a.name AS employee1, b.name AS employee2, shared AS sharedSkills
977
+ ORDER BY size(shared) DESC
978
+ ```
979
+
894
980
  ## Contributing
895
981
 
896
982
  This project welcomes contributions and suggestions. Most contributions require you to agree to a