mirror of
https://github.com/alopexc0de/Simple-Bookmarking-Service.git
synced 2024-12-22 14:22:39 +00:00
Move Database into API, minor tweaks
This commit is contained in:
parent
0b0db7ab4a
commit
200ed14d13
@ -95,13 +95,13 @@ class Database:
|
|||||||
exist in the database adding a new entry if that
|
exist in the database adding a new entry if that
|
||||||
is the case. If the `uri` is already stored
|
is the case. If the `uri` is already stored
|
||||||
(based on the generated UUID), the existing
|
(based on the generated UUID), the existing
|
||||||
entry will be returned instead.
|
entry's UUID will be returned instead.
|
||||||
"""
|
"""
|
||||||
uri_uuid = uuid.uuid5(uuid.NAMESPACE_URL, uri)
|
uri_uuid = uuid.uuid5(uuid.NAMESPACE_URL, uri)
|
||||||
|
|
||||||
bookmark_exists = self.get_bookmark(uri_uuid)
|
bookmark_exists = self.get_bookmark(uri_uuid)
|
||||||
if bookmark_exists != None:
|
if bookmark_exists != None:
|
||||||
return bookmark_exists
|
return bookmark_exists[0]
|
||||||
|
|
||||||
query = """
|
query = """
|
||||||
INSERT INTO bookmarks (
|
INSERT INTO bookmarks (
|
||||||
@ -125,6 +125,10 @@ class Database:
|
|||||||
query = "DELETE FROM bookmarks WHERE bookmark_id = ?"
|
query = "DELETE FROM bookmarks WHERE bookmark_id = ?"
|
||||||
self.cursor.execute(query, (bookmark_id, ))
|
self.cursor.execute(query, (bookmark_id, ))
|
||||||
|
|
||||||
|
if self.get_bookmark(bookmark_id) == None:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def update_bookmark_title(self, bookmark_id, new_title):
|
def update_bookmark_title(self, bookmark_id, new_title):
|
||||||
"""
|
"""
|
||||||
Takes the provided `bookmark_id`, searches the
|
Takes the provided `bookmark_id`, searches the
|
Loading…
Reference in New Issue
Block a user