Any data class in pymemri inherits from Item. It is a base class for items with some handy functionalities to create new items and edges, retrieve all edges to other items, and sync with the pod.

class Edge

Edge(source, target, _type, label=None, sequence=None, created=False, reverse=True)

Edges makes a link between two ItemBase Items. You won't use this class a lot in practice, as edges are abstracted away for normal users. When items are retrieved from the database, the edges are parsed automatically. When you add an edge between to items within pymemri, you will often use ItemBase.add_edge



We can traverse an edge starting from the source to the target or vice versa. In practice we often call item.some_edge_type, which calls item.traverse(edgetype), which in turn calls this function.

class Item

Item(dateCreated:datetime=None, dateModified:datetime=None, dateServerModified:datetime=None, deleted:bool=None, externalId:str=None, itemDescription:str=None, starred:bool=None, version:str=None, id:str=None, importJson:str=None, pluginClass:str=None, changelog:list=None, label:list=None, genericAttribute:list=None, measure:list=None, sharedWith:list=None) :: ItemBase

Item is the baseclass for all of the data classes.


ItemBase.add_edge(name, val)

Creates an edge of type name and makes it point to val



returns whether the node is expanded. An expanded node retrieved nodes that are directly connected to it from the pod, and stored their values via edges in the object.


With the Item and Edge classes we can create an item and its surrounding graph. The schema is defined in, in general we want to use the from_data staticmethod to generate new items, because it ensures that edges are linked from both the source and the target object. Let's make a new item and add it to the pod.

class MyItem(Item):
    properties = + ["name", "age"]
    edges = Item.edges + ["friend"]
    def __init__(self, name: str=None, age: int=None,friend: list=None, **kwargs):
        super().__init__(**kwargs) = name
        self.age = age
        self.friend = fried if friend is not None else []
from pymemri.pod.client import PodClient
client = PodClient()
assert client.add_to_schema(MyItem(name="abc", age=1))
x = MyItem(name="me", age=30)
target = MyItem(name="my friend", age=31)
x.add_edge("friend", MyItem(name="my friend", age=31))

We can now create our MyItem, as a side-effect of creating it, it will receive an id

assert client.create(x)
y = client.get(
assert len(y.friend) > 0
assert y.friend[0].name == "my friend"
assert == "me"
assert y.age == 30
# One year later
y.age = 31
y.add_edge("friend", MyItem(name="my friend2", age=29))
assert y.age == 31
assert len(y.friend) == 2
updating MyItem (#fbe0cba474cb9e20cb7e994d775ba111)
BULK: Writing 2/2 items/edges
400 Failure: JSON deserialization error payload.createEdges[0]._target: invalid type: null, expected a string at line 1 column 245
could not complete bulk action, aborting
[MyItem (#None), MyItem (#None)]
{'id': 'fbe0cba474cb9e20cb7e994d775ba111',
 'deleted': False,
 'name': 'me',
 'age': 31,
 'type': 'MyItem'}