eve_neo4j/neo4j.py
def insert(self, resource, doc_or_docs):
        """ Inserts a document as a node with a label.

        :param resource: resource being accessed.
        :param doc_or_docs: json document or list of json documents to be added
                            to the database.
        """
        indexes = []
        label, _, _, _ = self._datasource_ex(resource, [])
        id_field = config.DOMAIN[resource]['id_field']
        relation = config.DOMAIN[resource]['datasource']['relation']
        schema = config.DOMAIN[resource]['schema']

        tx = self.driver.graph.begin()
        for document in doc_or_docs:
            if relation:
                properties = prepare_properties(document)
                start_node = self._node_by_id(
                    properties.pop('start_node'),
                    schema['start_node']['data_relation']['resource'])
                end_node = self._node_by_id(
                    properties.pop('end_node'),
                    schema['end_node']['data_relation']['resource'])
                relation = Relationship(
                    start_node, label, end_node, **properties)
                relation[id_field] = str(uuid.uuid4())
                tx.create(relation)
                indexes.append(relation[id_field])
            else:
                node = create_node(label, document)
                node[id_field] = str(uuid.uuid4())
                tx.create(node)
                indexes.append(node[id_field])
        tx.commit()
        return indexes
 Inserts a document as a node with a label.

        :param resource: resource being accessed.
        :param doc_or_docs: json document or list of json documents to be added
                            to the database.
        
Inserts a document as a node with a label.
Inserts a document as a node with a label .
def insert(self, resource, doc_or_docs):
        indexes = []
        label, _, _, _ = self._datasource_ex(resource, [])
        id_field = config.DOMAIN[resource]['id_field']
        relation = config.DOMAIN[resource]['datasource']['relation']
        schema = config.DOMAIN[resource]['schema']
        tx = self.driver.graph.begin()
        for document in doc_or_docs:
            if relation:
                properties = prepare_properties(document)
                start_node = self._node_by_id(
                    properties.pop('start_node'),
                    schema['start_node']['data_relation']['resource'])
                end_node = self._node_by_id(
                    properties.pop('end_node'),
                    schema['end_node']['data_relation']['resource'])
                relation = Relationship(
                    start_node, label, end_node, **properties)
                relation[id_field] = str(uuid.uuid4())
                tx.create(relation)
                indexes.append(relation[id_field])
            else:
                node = create_node(label, document)
                node[id_field] = str(uuid.uuid4())
                tx.create(node)
                indexes.append(node[id_field])
        tx.commit()
        return indexes
def insert ( self , resource , doc_or_docs ) : indexes = [ ] label , _ , _ , _ = self . _datasource_ex ( resource , [ ] ) id_field = config . DOMAIN [ resource ] [ 'id_field' ] relation = config . DOMAIN [ resource ] [ 'datasource' ] [ 'relation' ] schema = config . DOMAIN [ resource ] [ 'schema' ] tx = self . driver . graph . begin ( ) for document in doc_or_docs : if relation : properties = prepare_properties ( document ) start_node = self . _node_by_id ( properties . pop ( 'start_node' ) , schema [ 'start_node' ] [ 'data_relation' ] [ 'resource' ] ) end_node = self . _node_by_id ( properties . pop ( 'end_node' ) , schema [ 'end_node' ] [ 'data_relation' ] [ 'resource' ] ) relation = Relationship ( start_node , label , end_node , ** properties ) relation [ id_field ] = str ( uuid . uuid4 ( ) ) tx . create ( relation ) indexes . append ( relation [ id_field ] ) else : node = create_node ( label , document ) node [ id_field ] = str ( uuid . uuid4 ( ) ) tx . create ( node ) indexes . append ( node [ id_field ] ) tx . commit ( ) return indexes
Inserts a document as a node with a label.
Inserts a document as a node with a label .
""" Inserts a document as a node with a label.

        :param resource: resource being accessed.
        :param doc_or_docs: json document or list of json documents to be added
                            to the database.
        """
self
resource
resource being accessed.
resource being accessed .
doc_or_docs
json document or list of json documents to be added
to the database.
json document or list of json documents to be added to the database .