in resdb_orm/orm.py [0:0]
def create(self, data):
"""Create a new record in the DB."""
token = self.generate_token()
payload = {"id":token, "data":data}
headers = {'Content-Type': 'application/json'}
response = requests.post(f'{self.db_root_url}/v1/transactions/commit',
data=json.dumps(payload), headers=headers)
# Check if response is successful and handle empty response content
if response.status_code == 201:
if response.content:
decoded_content = response.content.decode('utf-8')
id_value = decoded_content.split(': ')[1].strip()
return id_value
else:
return {"status": "create unsuccessful, no content in response"}