Copy
Ask AI
::FromN
Example 1: Getting the user from a document creation edge
Copy
Ask AI
QUERY GetCreatorFromEdge (creation_id: ID) =>
creator <- E<Creates>(creation_id)::FromN
RETURN creator
QUERY CreateUser (name: String, email: String) =>
user <- AddN<User>({
name: name,
email: email,
})
RETURN user
QUERY CreateDocument (user_id: ID, content: String, vector: [F64]) =>
document <- AddV<Document>(vector, {
content: content
})
creation_edge <- AddE<Creates>::From(user_id)::To(document)
RETURN creation_edge
Copy
Ask AI
from helix.client import Client
client = Client(local=True, port=6969)
alice = client.query("CreateUser", {"name": "Alice", "email": "alice@example.com"})
alice_id = alice[0]["user"]["id"]
creation = client.query("CreateDocument", {
"user_id": alice_id,
"content": "This is my first document",
"vector": [0.1, 0.2, 0.3, 0.4, 0.5],
})
creation_id = creation[0]["creation_edge"]["id"]
result = client.query("GetCreatorFromEdge", {
"creation_id": creation_id,
})
print(result)
::FromV
Source Vector
Return the vector (node plus its properties) that the edge originates from.
Copy
Ask AI
::FromV
Example 1: Inspecting the document vector from edge
Copy
Ask AI
QUERY GetDocumentVector (creation_id: ID) =>
document_vector <- E<Creates>(creation_id)::ToV
RETURN document_vector
QUERY CreateUser (name: String, email: String) =>
user <- AddN<User>({
name: name,
email: email,
})
RETURN user
QUERY CreateDocument (user_id: ID, content: String, vector: [F64]) =>
document <- AddV<Document>(vector, {
content: content
})
creation_edge <- AddE<Creates>::From(user_id)::To(document)
RETURN creation_edge
Copy
Ask AI
from helix.client import Client
client = Client(local=True, port=6969)
alice = client.query("CreateUser", {"name": "Alice", "email": "alice@example.com"})
alice_id = alice[0]["user"]["id"]
creation = client.query("CreateDocument", {
"user_id": alice_id,
"content": "This is my first document",
"vector": [0.1, 0.2, 0.3, 0.4, 0.5],
})
creation_id = creation[0]["creation_edge"]["id"]
vector = client.query("GetDocumentVector", {
"creation_id": creation_id,
})
print(vector)
::ToN
Destination Node
Return the node that the edge points to.
Copy
Ask AI
::ToN
Example 1: Getting the followed user from a follow edge
Copy
Ask AI
QUERY GetFollowedUser (follow_id: ID) =>
followed_user <- E<Follows>(follow_id)::ToN
RETURN followed_user
QUERY CreateUser (name: String, email: String) =>
user <- AddN<User>({
name: name,
email: email,
})
RETURN user
QUERY FollowUser (follower_id: ID, followed_id: ID, since: String) =>
follow_edge <- AddE<Follows>::From(follower_id)::To(followed_id)
RETURN follow_edge
Copy
Ask AI
from helix.client import Client
from datetime import datetime
client = Client(local=True, port=6969)
alice = client.query("CreateUser", {"name": "Alice", "email": "alice@example.com"})
alice_id = alice[0]["user"]["id"]
bob = client.query("CreateUser", {"name": "Bob", "email": "bob@example.com"})
bob_id = bob[0]["user"]["id"]
since_value = datetime.now().isoformat()
follow = client.query("FollowUser", {
"follower_id": alice_id,
"followed_id": bob_id,
"since": since_value,
})
follow_id = follow[0]["follow_edge"]["id"]
followed_user = client.query("GetFollowedUser", {
"follow_id": follow_id,
})
print(followed_user)
::ToV
Destination Vector
Return the vector that the edge points to.
Copy
Ask AI
::ToV
Example 1: Inspecting the document vector
Copy
Ask AI
QUERY GetDocumentVector (creation_id: ID) =>
document_vector <- E<Creates>(creation_id)::ToV
RETURN document_vector
QUERY CreateUser (name: String, email: String) =>
user <- AddN<User>({
name: name,
email: email,
})
RETURN user
QUERY CreateDocument (user_id: ID, content: String, vector: [F64]) =>
document <- AddV<Document>(vector, {
content: content
})
creation_edge <- AddE<Creates>::From(user_id)::To(document)
RETURN creation_edge
Copy
Ask AI
from helix.client import Client
client = Client(local=True, port=6969)
alice = client.query("CreateUser", {"name": "Alice", "email": "alice@example.com"})
alice_id = alice[0]["user"]["id"]
creation = client.query("CreateDocument", {
"user_id": alice_id,
"content": "This is my first document",
"vector": [0.1, 0.2, 0.3, 0.4, 0.5],
})
creation_id = creation[0]["creation_edge"]["id"]
vector = client.query("GetDocumentVector", {
"creation_id": creation_id,
})
print(vector)