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

Searching for nodes where query must match a value in an array in the body #17

Closed
rajarshi opened this issue Dec 13, 2022 · 3 comments
Closed

Comments

@rajarshi
Copy link

I'm looking to do something like this

from simple_graph_sqlite import database as db 
dbfile = "db.sqlite"

db.initialize(dbfile)

db.atomic(dbfile, db.add_node({'name': 'foo', 'type':['company', 'start-up']}, 1))
db.atomic(dbfile, db.add_node({'name': 'bar', 'type':['cat', 'apple']}, 1))

db.atomic(apple, db.find_nodes({'type': 'apple'}, db._search_like, db._search_starts_with))

But I don't think the last statement works

@dpapathanasiou
Copy link
Owner

Hi @rajarshi

You're right, the current search statements do not introspect the json object correctly; looking at the sqlite json docs, it seems that statement need to use json_each.value LIKE ... or json_tree.type IN ... instead.

I can tinker with this some more, to see how to introduce those; ideally, I'd like to include them as statements in the sql so they're usable by any programming language that supports sql bindings, rather than coming up with a python-specific solution.

@rajarshi
Copy link
Author

Got it, thanks

@dpapathanasiou
Copy link
Owner

Hi @rajarshi

I've recently revamped the search functions for allow for this; see the test and the updated example for how it works now, using the search templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants