Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any recommended way for deleting entries? #19

Open
antropolouco opened this issue Nov 15, 2024 · 1 comment
Open

Any recommended way for deleting entries? #19

antropolouco opened this issue Nov 15, 2024 · 1 comment

Comments

@antropolouco
Copy link

Hey there, how are you?

I found your solution and it works fine for me, but it seems to have no admin control or whatever.

Considering login-less is exposed to any harmful messages or SPAMs, how can I DELETE any entries if I need?

Thanks in advance!

@antropolouco
Copy link
Author

antropolouco commented Dec 13, 2024

Well, shortly after opening this issue, I went to the hard/RAW approach. This project seems abandoned(?), so it's likely that no friendly method for editing and deleting entries will be incorporated here (at least not from the original developer).

Anyway, if you need to edit (or in this case, delete) an entry directly in the database, here is what I do:

First, get access to the docker shell, executing psql automatically:


# docker exec -u postgres -ti guestbook_db_1 psql

I assume you are using the root user (or your user have permission to access the docker directly), so if needed you can add "sudo" before the command.

Then, connect to the proper database:


# \c guestbook

Now that you are connected, you can list all of the guestbook entries/messages:


# SELECT * FROM entries;

It will provide a full list of the entries. Choose which one you want to delete from the guestbook, get its ID and use this number to delete the entry:


# DELETE FROM entries WHERE ID = X;

Replace "X" with the entry's ID you want to delete and...
You are done! Quit the database server and the docker sending a \q command.

PLUS
For editing an entry, when already connected to the database, you can send the following command:


UPDATE entries SET created = '2023-11-16 00:17:03.930071' WHERE ID = X;

Once again, replace "X" with your entry's ID. In this example, we are changing only the "created" column (the date in which a message was posted), but you can also edit "name", for changing the person's name who sent a message, and "comment" to edit the message itself, instead.

Best regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant