"_id": "U1IT00001", "item_name": "Blender", "max_discount": "50%", "batch_number": "RR450020FRG", "price": 450, "category": "kitchen appliance" } # But before we update it in Mongo, I want to review the changes first # Create a TerminusX client (see https://dashboard.terminusdb.com/profile) tbd_endpoint = WOQLClient("http://localhost:6363/") # Find the item back from database in case someone already changed it item_1 = collection_name.find_one({"item_name": "Blender"}) patch = tbd_endpoint.diff(item_1, new_item_1) pprint(patch.content) # If we apprive, then proceed collection_name.update_one(patch.before, {"$set": patch.update}) # Working on more complicated objects expiry_date = '2021-07-15T00:00:00.000' expiry = dt.datetime.fromisoformat(expiry_date) new_item_3 = { "item_name": "Bread", "quantity": 5, "ingredients": "all-purpose flour", "expiry_date": expiry
# create a client endpoint client = WOQLClient("http://*****:*****@id": "Person/Jane", "@type": "Person", "name": "Jane"} janine = {"@id": "Person/Jane", "@type": "Person", "name": "Janine"}