Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-30-2020 01:28 PM
Hi all,
I'm building a django application with neo4j and have built 3 models. My question is how can I connect them with relationships and use this in a simple cypher query where data from at least 2 models is used?
Note that I added a comment (# key) to the model fields which are the keys.
class Products(StructuredNode):
uid = UniqueIdProperty()
sku = StringProperty(unique_index=True, required=True) #key
product = StringProperty()
brand = StringProperty()
gender = StringProperty()
fit = StringProperty()
color = StringProperty()
class Clicks(StructuredNode):
uid = UniqueIdProperty()
user_email = StringProperty() #key
click_date = DateTimeProperty()
click_sku = StringProperty() #key
class Users(StructuredNode):
uid = UniqueIdProperty()
user_email = StringProperty(unique_index=True) #key
username = StringProperty()
Cypher query in django view where only one model is used:
def feed(request):
query = 'MATCH (n:Products) RETURN n LIMIT 10'
results, _ = db.cypher_query(query)
products = [Products.inflate(row[0]) for row in results]
context = {'products':products} # resultaten hiervan checken
return render(request, 'feed/feed.html', context)
If anybody can help me out by illustrating what I've to add to my models and how to use at least 2 models with a relation in the cypher query, that would be really awesome.
All the sessions of the conference are now available online