When I try to "GET" a nonexistent barcode, the code will automatically populate an entry with NULL entries for all except the barcode num (e.g., if I try to get the barcode "xxxxx" it will add that into the DB with type, name, etc. set to NULL). This is fine!
However, there is no way to edit this barcode anymore... if you use the "barcode/add" call with the same barcode num in order to modify it, then you get an error ((1062, "Duplicate entry 'xxxxxx' for key 'PRIMARY'")). So, the only thing I can do is call "GET" on an all-NULL entry.
I have 3 suggestions (choose 1, not all):
(1) Modify the "barcode/get" API to not insert a NULL'd entry, OR
(2) Modify the "barcode/add" API to update an existing entry when using a duplicate PRIMARY key, OR
(3) Create a new endpoint called "barcode/update" that allows for the updating of entries.
Let me know what you think. I think (3) is the best option, because you don't need to modify the "get" or "add" endpoints. I think (2) is a bad design choice (getting the error message is a good thing) and (1) is debatable (maybe just return a message without adding a NULL'd entry?)
Hi, please view the following lines for the "get barcode" API - https://github.com/zotbins/ZotBinsAPI/blob/af17e16c9af6f3da0634f6a64621f4f7f42e5424/ZotBinsAPI.py#L227-L239
When I try to "GET" a nonexistent barcode, the code will automatically populate an entry with NULL entries for all except the barcode num (e.g., if I try to get the barcode "xxxxx" it will add that into the DB with type, name, etc. set to NULL). This is fine!
However, there is no way to edit this barcode anymore... if you use the "barcode/add" call with the same barcode num in order to modify it, then you get an error ((1062, "Duplicate entry 'xxxxxx' for key 'PRIMARY'")). So, the only thing I can do is call "GET" on an all-NULL entry.
I have 3 suggestions (choose 1, not all): (1) Modify the "barcode/get" API to not insert a NULL'd entry, OR (2) Modify the "barcode/add" API to update an existing entry when using a duplicate PRIMARY key, OR (3) Create a new endpoint called "barcode/update" that allows for the updating of entries.
Let me know what you think. I think (3) is the best option, because you don't need to modify the "get" or "add" endpoints. I think (2) is a bad design choice (getting the error message is a good thing) and (1) is debatable (maybe just return a message without adding a NULL'd entry?)