How to use the neomodel.IntegerProperty function in neomodel

To help you get started, we’ve selected a few neomodel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neo4j-contrib / neomodel / test / test_issue_87.py View on Github external
twelve_days = timedelta(days=12)
eleven_days = timedelta(days=11)
ten_days = timedelta(days=10)
nine_days = timedelta(days=9)
now = datetime.now()


class FriendRelationship(StructuredRel):
    since = DateTimeProperty(default=datetime.now)


class Person(StructuredNode):
    name = StringProperty()
    age = IntegerProperty()
    friends = Relationship('Person', 'friend_of', model=FriendRelationship)


def setup_friends(person0, person1, since=None):
    rel = person0.friends.connect(person1)
    if (since):
        rel.since = since
        rel.save()
    return rel.since


def test_traversal_single_param():
    connection().clear()
    jean = Person(name="Jean", age=25).save()
    johan = Person(name="Johan", age=19).save()
    chris = Person(name="Chris", age=21).save()
github neo4j-contrib / neomodel / test / test_models.py View on Github external
def test_inheritance():
    class User(StructuredNode):
        __abstract_node__ = True
        name = StringProperty(unique_index=True)

    class Shopper(User):
        balance = IntegerProperty(index=True)

        def credit_account(self, amount):
            self.balance = self.balance + int(amount)
            self.save()

    jim = Shopper(name='jimmy', balance=300).save()
    jim.credit_account(50)

    assert Shopper.__label__ == 'Shopper'
    assert jim.balance == 350
    assert len(jim.inherited_labels()) == 1
    assert len(jim.labels()) == 1
    assert jim.labels()[0] == 'Shopper'
github neo4j-contrib / neomodel / test / test_models.py View on Github external
def test_mixins():
    class UserMixin(object):
        name = StringProperty(unique_index=True)
        password = StringProperty()

    class CreditMixin(object):
        balance = IntegerProperty(index=True)

        def credit_account(self, amount):
            self.balance = self.balance + int(amount)
            self.save()

    class Shopper2(StructuredNode, UserMixin, CreditMixin):
        pass

    jim = Shopper2(name='jimmy', balance=300).save()
    jim.credit_account(50)

    assert Shopper2.__label__ == 'Shopper2'
    assert jim.balance == 350
    assert len(jim.inherited_labels()) == 1
    assert len(jim.labels()) == 1
    assert jim.labels()[0] == 'Shopper2'
github neo4j-contrib / neomodel / test / test_batch.py View on Github external
from pytest import raises

from neomodel import (StructuredNode, StringProperty, IntegerProperty, UniqueIdProperty,
                      RelationshipTo, RelationshipFrom)
from neomodel.exceptions import UniqueProperty, DeflateError


class UniqueUser(StructuredNode):
    uid = UniqueIdProperty()
    name = StringProperty()
    age = IntegerProperty()


def test_unique_id_property_batch():
    users = UniqueUser.create(
        {'name': 'bob', 'age': 2},
        {'name': 'ben', 'age': 3}
    )

    assert users[0].uid != users[1].uid

    users = UniqueUser.get_or_create(
        {'uid': users[0].uid},
        {'name': 'bill', 'age': 4}
    )

    assert users[0].name == 'bob'
github romaintha / twitter / twitter / models.py View on Github external
mentions = neomodel.RelationshipTo('User', 'MENTIONS')
    replies = neomodel.RelationshipTo('Tweet', 'REPLIES')
    tags = neomodel.RelationshipTo('Hashtag', 'TAGS')
    contains = neomodel.RelationshipTo('Link', 'CONTAINS')
    quotes = neomodel.Relationship('Tweet', 'QUOTES')

    def save(self):
        self.modified = datetime.datetime.now()
        super(Tweet, self).save()


class User(neomodel.StructuredNode):
    id_str = neomodel.StringProperty(unique_index=True, required=True)
    name = neomodel.StringProperty(required=False)
    screen_name = neomodel.StringProperty(required=False)
    followers_count = neomodel.IntegerProperty(required=False)
    friends_count = neomodel.IntegerProperty(required=False)
    modified = neomodel.DateTimeProperty(required=False)
    created_at = neomodel.DateTimeProperty(required=False)
    description = neomodel.StringProperty(required=False)
    location = neomodel.StringProperty(required=False)
    coordinates = neomodel.ArrayProperty(required=False, default=[])
    time_zone = neomodel.StringProperty(required=False)
    url = neomodel.StringProperty(required=False)
    lang = neomodel.StringProperty(required=False)

    follows = neomodel.RelationshipTo('User', 'FOLLOWS')
    posts = neomodel.RelationshipTo('Tweet', 'POSTS')

    def save(self):
        self.modified = datetime.datetime.now()
        super(User, self).save()
github cznewt / architect-api / architect / manager / graph_models.py View on Github external
from neomodel import StructuredNode, StringProperty, \
    IntegerProperty, JSONProperty
from neomodel.match import OUTGOING, INCOMING, EITHER
from neomodel.relationship_manager import RelationshipManager
from neomodel.relationship import StructuredRel
from architect import utils

registry = utils.ClassRegistry()


class ResourceRel(StructuredRel):
    size = IntegerProperty(default=1)
    status = StringProperty(default='unknown')


class RelationshipDefinition(object):
    def __init__(self, relation_type, cls_name, direction,
                 manager=RelationshipManager,
                 model=None):
        self._raw_class = cls_name
        self.manager = manager
        self.definition = {}
        self.definition['relation_type'] = relation_type
        self.definition['direction'] = direction
        self.definition['model'] = model

    def _lookup_node_class(self):
        if not isinstance(self._raw_class, str):
github xchem / fragalysis / frag / network / django_models.py View on Github external
residue_number = StringProperty()
    res_id = StringProperty()
    # Connect SpecificResidue to GeneralResidue and Protein
    # and SpecificResidue to SpecificResidue based on orientation and distance


class SpecificResidueFeature(StructuredNode):
    """
    A pharmacophore feature for a given SpecificResidue
    """
    # Unique id - PDBID:CHAINID:RES_NUM:ALTLOC:PHARMATYPE:INDEX
    unique_string = StringProperty(unique_index=True)
    # The 3 Letter code residue id
    res_id = StringProperty()
    pharma_type = StringProperty()
    index = IntegerProperty()
    # Connect to SpecificResidue and
github xchem / fragalysis / frag / network / django_models.py View on Github external
exclude_type = StringProperty()
    rebuilt_smiles = StringProperty()
    rebuilt_ring_smiles = StringProperty()
    rebuilt_type = StringProperty()
    excluded_ring_smiles = StringProperty()
    # The Exclude and Rebuilt smiles combined
    both_sides = StringProperty(unique_index=True)


class BaseMolecule(StructuredNode):
    smiles = StringProperty(unique_index=True)
    heavy_atom_count = IntegerProperty()
    ring_atom_count = IntegerProperty()
    ring_smiles = StringProperty()
    # Annotations of price and molecule id
    price = IntegerProperty()
    mol_id = StringProperty()


class Compound(BaseMolecule):
    """
    A molecule - a real purchasable molecule
    """
    fragments = RelationshipTo("Fragment", "FRAG")
    conformers = RelationshipTo("Conformer", "CONFEDGE")
    parent_molecules = RelationshipTo("Compound", "PARENTEDGE")


class Fragment(BaseMolecule):
    """
    A fragment - not a real molecule
    """
github varchashva / LetsMapYourNetwork / core / models.py View on Github external
# class isConnected(Relationship):
#     neighbour = DateTime(default=current_datetime, nullable=False)


from neomodel import (config, StructuredNode, StringProperty, IntegerProperty,
    UniqueIdProperty, RelationshipTo, RelationshipFrom, Relationship)

config.DATABASE_URL = 'bolt://neo4j:Neo4j@localhost:7687'

class Machine(StructuredNode):
    uid = UniqueIdProperty()
    ip = StringProperty(unique_index=True)
    subnet = StringProperty(unique_index=True)
    hostname = StringProperty(unique_index=True)
    tag = StringProperty(unique_index=True)
    distance = IntegerProperty()
    queue = IntegerProperty()
    connected = Relationship('Machine','IS_CONNECTED')
    # objects = StructuredNode.Manager()
    # age = IntegerProperty(index=True, default=0)
    def __str__(self):
        return self.hostname
github varchashva / LetsMapYourNetwork / core / models.py View on Github external
#     neighbour = DateTime(default=current_datetime, nullable=False)


from neomodel import (config, StructuredNode, StringProperty, IntegerProperty,
    UniqueIdProperty, RelationshipTo, RelationshipFrom, Relationship)

config.DATABASE_URL = 'bolt://neo4j:Neo4j@localhost:7687'

class Machine(StructuredNode):
    uid = UniqueIdProperty()
    ip = StringProperty(unique_index=True)
    subnet = StringProperty(unique_index=True)
    hostname = StringProperty(unique_index=True)
    tag = StringProperty(unique_index=True)
    distance = IntegerProperty()
    queue = IntegerProperty()
    connected = Relationship('Machine','IS_CONNECTED')
    # objects = StructuredNode.Manager()
    # age = IntegerProperty(index=True, default=0)
    def __str__(self):
        return self.hostname