Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Neo4j's create index syntax #225

Open
gitbuda opened this issue Mar 15, 2023 · 2 comments
Open

Add support for Neo4j's create index syntax #225

gitbuda opened this issue Mar 15, 2023 · 2 comments
Labels
community community Effort - Medium Effort - Medium feature feature Frequency - EveryTime Frequency - EveryTime Priority - Later Priority - Later Reach - Some Reach - Some Severity - S3 Severity - S3

Comments

@gitbuda
Copy link
Member

gitbuda commented Mar 15, 2023

CREATE INDEX FOR

Screenshot 2023-03-15 at 8 00 23 PM

SOURCE

@ghost
Copy link

ghost commented Mar 16, 2023

To reproduce just use the entire code example from the docs and replace db = Memgraph() with a Neo4j connection and run:

from gqlalchemy import Memgraph, Neo4j, Node, Relationship, Field
from typing import Optional

# db = Memgraph()
db = Neo4j(host="localhost", username="neo4j", password="neo4j")

class User(Node):
    id: str = Field(index=True, db=db)
    username: str = Field(exists=True, db=db)


class Streamer(User):
    id: str
    username: Optional[str] = Field(exists=True, db=db)
    followers: Optional[str]
    tst: Optional[str]


class Language(Node, index=True, db=db):
    name: str = Field(unique=True, db=db)


class ChatsWith(Relationship, type="CHATS_WITH"):
    last_chatted: str


class Speaks(Relationship, type="SPEAKS"):
    since: Optional[str]


john = User(id="1", username="John").save(db)
jane = Streamer(id="2", username="janedoe", followers=111).save(db)
language = Language(name="en").save(db)

ChatsWith(
    _start_node_id=john._id, _end_node_id=jane._id, last_chatted="2023-02-14"
).save(db)

Speaks(_start_node_id=john._id, _end_node_id=language._id, since="2023-02-14").save(db)

streamer = Streamer(id="2").load(db=db)
language = Language(name="en").load(db=db)

speaks = Speaks(
    _start_node_id=streamer._id,
    _end_node_id=language._id,
    since="2023-02-20",
).save(db)

speaks = Speaks(_start_node_id=streamer._id, _end_node_id=language._id).load(db)
print(speaks.since)

try:
    streamer = Streamer(id="3").load(db=db)
except:
    print("Creating new Streamer node in the database.")
    streamer = Streamer(id="3", username="anne", followers=222).save(db=db)

try:
    speaks = Speaks(_start_node_id=streamer._id, _end_node_id=language._id).load(db)
except:
    print("Creating new Speaks relationship in the database.")
    speaks = Speaks(
        _start_node_id=streamer._id,
        _end_node_id=language._id,
        since="2023-02-20",
    ).save(db)

print(db.get_indexes())
print(db.get_constraints())

@katarinasupe katarinasupe added the type: enhancement New feature or request label Mar 31, 2023
@Ankan1998
Copy link

Yes I am also looking forward to it.

@katarinasupe katarinasupe added Importance - I3 Importance - I3 Severity - S3 Severity - S3 Effort - Medium Effort - Medium feature feature community community and removed type: enhancement New feature or request labels Dec 28, 2023
@hal-eisen-MG hal-eisen-MG added Priority - Later Priority - Later and removed Priority - Later Priority - Later labels Feb 4, 2024
@hal-eisen-MG hal-eisen-MG added Priority - Later Priority - Later and removed Priority - Later Priority - Later labels Feb 18, 2024
@katarinasupe katarinasupe added Frequency - EveryTime Frequency - EveryTime Reach - Some Reach - Some and removed Importance - I3 Importance - I3 labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community community Effort - Medium Effort - Medium feature feature Frequency - EveryTime Frequency - EveryTime Priority - Later Priority - Later Reach - Some Reach - Some Severity - S3 Severity - S3
Projects
Status: Todo
Development

No branches or pull requests

4 participants