Update exiting data


#1

Hello,

I’m storing temperature sensor output which is an integer into KB. But, I get get frequent updates on that value. How can I update that property in KB?


#2

What I’m trying to do in the python client is

def updateAttribute(thing, type, value):
    for attr in thing.keys(type):
        thing.unhas(attr)
    if value is None:
        return
    if value == '':
        return
    attribute = type.create(value)
    thing.has(attribute)

“has” adds attributes (more than one of the same type can be added; entities can have 2 names, for instance)
I think “unhas” does the opposite. But I’m running into an issue with this: Error running unhas: RelationshipReified cannot be cast to Relationship . So I don’t know if I’m doing it right.

Also, I don’t think “unhas” exists in graql. I don’t know if updating is possible using only graql


#3

I found another answer on the forum: How can I retrieve an instance and then update it with GRAQL?