diff --git a/velconnect/CreateDB.sql b/velconnect/CreateDB.sql index 380017c..ebc88b8 100644 --- a/velconnect/CreateDB.sql +++ b/velconnect/CreateDB.sql @@ -72,7 +72,7 @@ CREATE TABLE `DataBlock` ( `id` TEXT NOT NULL, -- id of the owner of this file. Ownership is not transferable because ids may collide, -- but the owner could be null for global scope - `owner_id` TEXT NOT NULL DEFAULT 'none', + `owner_id` TEXT, `visibility` TEXT CHECK( `visibility` IN ('public','private','unlisted') ) NOT NULL DEFAULT 'public', -- This is an indexable field to filter out different types of datablocks `category` TEXT, diff --git a/velconnect/routes/api.py b/velconnect/routes/api.py index b89261b..0db9cd2 100644 --- a/velconnect/routes/api.py +++ b/velconnect/routes/api.py @@ -264,9 +264,19 @@ def set_data(request: fastapi.Request, data: dict, key: str = None, owner: str = # add the data to the db db.insert(""" - REPLACE INTO `DataBlock` (id, category, modified_by, data, last_modified) - VALUES(:id, :category, :modified_by, :data, CURRENT_TIMESTAMP); - """, {"id": key, "category": category, "modified_by": modified_by, "data": json.dumps(data)}) + REPLACE INTO `DataBlock` (id, owner_id, category, modified_by, data, last_modified) + VALUES(:id, :owner_id, :category, :modified_by, :data, CURRENT_TIMESTAMP); + """, {"id": key, "owner_id": owner, "category": category, "modified_by": modified_by, "data": json.dumps(data)}) + + # # add the data to the db + # db.insert(""" + # REPLACE INTO `DataBlock` SET + # category = :category, + # modified_by = :modified_by, + # data = :data, + # last_modified = CURRENT_TIMESTAMP + # WHERE id=:id AND owner_id = :owner_id; + # """, {"id": key, "category": category, "modified_by": modified_by, "owner_id": owner, "data": json.dumps(data)}) return {'key': key}