Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oakfang/graph-q
Query graph-core graphs
https://github.com/oakfang/graph-q
Last synced: 6 days ago
JSON representation
Query graph-core graphs
- Host: GitHub
- URL: https://github.com/oakfang/graph-q
- Owner: oakfang
- License: mit
- Created: 2019-02-14T12:36:58.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-04-28T22:29:38.000Z (over 2 years ago)
- Last Synced: 2024-12-09T22:49:51.382Z (about 1 month ago)
- Language: JavaScript
- Size: 67.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# graph-q
A query language over the @xgraph/core graph.
## Usage
```js
const q = require('graph-q');
const graph = require('./graph');// get all User typed vertices from the graph
const { users } = q(graph)`(users:User)`;
// embedding raw values
const { users } = q(graph)`(users:${q.raw('User')})`;
// get all vertices who have incoming edges from vertex id foo
const { results } = q(graph)`(#foo)-->(results)`;
// get all User typed vertices from the graph
// with the username "foobar"
q(graph)`(users:User{username:"foobar"})`;
// get all resources that have an edge into them
// from User typed vertices
q(graph)`(:User)-->(r:Resource)`;
// get all resources that are owned by users
q(graph)`(:User)-[:owns]->(r:Resource)`;
// get all users who own a resource
q(graph)`(?users:User)-[:owns]->(:Resource)`;
q(graph)`(:Resource)<-[:owns]-(users:User)`;
// use advanced mongo-like filtering
q(graph)`
(users:User{
name: {
$size: 4
}
})
`;
// pass query as a parameter
q(
graph,
`(users:User{
name: {
$size: 4
}
})`
);
```