🔍 Code Extractor

function get_dbo_houses_with_references_flocktypes_dbo_flocktypes

Maturity: 40

Queries a Neo4j graph database to retrieve dbo_FlockTypes nodes that are connected to a specific dbo_Houses node via a REFERENCES_FLOCKTYPES relationship.

File:
/tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
Lines:
1993 - 2000
Complexity:
simple

Purpose

This function is designed to traverse a graph database relationship between house records and flock type records. It's useful for applications that need to understand what types of flocks are associated with specific houses in a poultry or livestock management system. The function allows limiting the number of results returned to manage query performance and result set size.

Source Code

def get_dbo_houses_with_references_flocktypes_dbo_flocktypes(source_id, limit=100):
    """Get dbo_FlockTypes nodes connected to a dbo_Houses via REFERENCES_FLOCKTYPES"""
    query = """
    MATCH (source:dbo_Houses {id: $source_id})-[r:REFERENCES_FLOCKTYPES]->(target:dbo_FlockTypes)
    RETURN target
    LIMIT $limit
    """
    return run_query(query, {"source_id": source_id, "limit": limit})

Parameters

Name Type Default Kind
source_id - - positional_or_keyword
limit - 100 positional_or_keyword

Parameter Details

source_id: The unique identifier of the dbo_Houses node from which to start the relationship traversal. This should be a value that matches the 'id' property of a dbo_Houses node in the Neo4j database. Expected type is typically string or integer depending on the database schema.

limit: Maximum number of dbo_FlockTypes nodes to return from the query. Defaults to 100. This parameter helps control query performance and prevents returning excessively large result sets. Must be a positive integer.

Return Value

Returns the result of the run_query function, which typically contains a list or collection of dbo_FlockTypes nodes that match the query criteria. The exact return type depends on the implementation of run_query, but it likely returns a list of dictionaries or Neo4j Record objects containing the properties of the target dbo_FlockTypes nodes. Returns an empty collection if no matching relationships are found.

Dependencies

  • neo4j

Required Imports

from neo4j import GraphDatabase

Usage Example

# Assuming run_query is defined and Neo4j connection is configured
# Example 1: Get flock types for a specific house
house_id = "HOUSE_001"
flock_types = get_dbo_houses_with_references_flocktypes_dbo_flocktypes(house_id)

# Example 2: Limit results to 50
house_id = "HOUSE_002"
flock_types = get_dbo_houses_with_references_flocktypes_dbo_flocktypes(house_id, limit=50)

# Example 3: Process results
for record in flock_types:
    flock_type_node = record['target']
    print(f"Flock Type: {flock_type_node}")

Best Practices

  • Always validate that source_id exists in the database before calling this function to avoid empty result sets
  • Consider adjusting the limit parameter based on expected data volume and performance requirements
  • Ensure proper error handling around the run_query function call to catch database connection issues
  • The function depends on run_query being properly implemented with Neo4j connection management
  • Consider adding input validation for source_id and limit parameters to prevent invalid queries
  • Be aware that this function only traverses outgoing REFERENCES_FLOCKTYPES relationships from dbo_Houses nodes
  • Monitor query performance if the limit is set to very high values or if the graph has many relationships

Similar Components

AI-powered semantic similarity - components with related functionality:

  • function get_dbo_flocks_with_references_houses_dbo_houses 92.5% similar

    Retrieves dbo_Houses nodes from a Neo4j graph database that are connected to a specific dbo_Flocks node via a REFERENCES_HOUSES relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_dbo_flocks_with_references_flocktypes_dbo_flocktypes 89.9% similar

    Queries a Neo4j graph database to retrieve dbo_FlockTypes nodes that are connected to a specific dbo_Flocks node via a REFERENCES_FLOCKTYPES relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_dbo_establishment_with_references_flocktypes_dbo_flocktypes 86.8% similar

    Queries a Neo4j graph database to retrieve dbo_FlockTypes nodes that are connected to a specific dbo_Establishment node through a REFERENCES_FLOCKTYPES relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function create_references_flocktypes_relationship_v1 85.4% similar

    Creates a REFERENCES_FLOCKTYPES relationship in a Neo4j graph database between a dbo_Houses node and a dbo_FlockTypes node, with optional properties on the relationship.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
  • function get_all_dbo_flocktypes 84.2% similar

    Queries a Neo4j graph database to retrieve all nodes labeled as 'dbo_FlockTypes' with a configurable limit on the number of results returned.

    From: /tf/active/vicechatdev/neo4j_schema/neo4j_python_snippets.py
← Back to Browse