owenthereal / jqplay

A playground for jq, written in Go
https://jqplay.org
MIT License
743 stars 88 forks source link

How to delete jqplay links? #107

Open MudraLadani opened 3 years ago

MudraLadani commented 3 years ago

Hello,

I created a few jqplay links. I want to delete those links.

How can I accomplish that?

elpreguntador commented 3 years ago

Hello,

Same question.

It would also be interesting to include at least a "noindex" meta tag

mngau commented 2 years ago

Hi, same query here, I'd like to delete jqplay links I have created also.

loganmarchione commented 1 year ago

I'm no DBA, but couldn't you run a DELETE statement in the database? There are two tables.

In the example below, I have two snippets and I want to delete the first one. The id is 1 and the slug is 6hLv1cbafHE.

jqplay-db=# SELECT * FROM snippets;
 id |    slug     |                      j                      |  q   |                                                                 o                                                                  |          created_at           
----+-------------+---------------------------------------------+------+------------------------------------------------------------------------------------------------------------------------------------+-------------------------------
  1 | 6hLv1cbafHE | { "foo": { "bar": { "baz": 123 } } }        | .    | [{"name": "slurp", "enabled": false}, {"name": "null-input", "enabled": false}, {"name": "compact-output", "enabled": false}, {"na.| 2023-05-12 01:50:08.049929+00
    |             |                                             |      |.me": "raw-input", "enabled": false}, {"name": "raw-output", "enabled": false}, {"name": "sort-keys", "enabled": false}]            | 
  2 | 6Mm_RDQnBFC | {"foo": 42, "bar": "less interesting data"} | .foo | [{"name": "slurp", "enabled": false}, {"name": "null-input", "enabled": false}, {"name": "compact-output", "enabled": false}, {"na.| 2023-05-12 01:57:54.43762+00
    |             |                                             |      |.me": "raw-input", "enabled": false}, {"name": "raw-output", "enabled": false}, {"name": "sort-keys", "enabled": false}]            | 
(2 rows)

jqplay-db=# SELECT * FROM snippets_id_seq;
 last_value | log_cnt | is_called 
------------+---------+-----------
          2 |      32 | t
(1 row)

Run a SELECT first.

SELECT * FROM snippets WHERE slug = '6hLv1cbafHE';

Then run a DELETE.

DELETE FROM snippets WHERE slug = '6hLv1cbafHE' RETURNING *;

The first snippet is gone, and the new snippets continue to increment their IDs. I don't think this would be an issue, but I don't know enough about SQL to be sure. Regardless, this is what I'm doing and it seems to work 🤷.

jqplay-db=# SELECT * FROM snippets;
 id |    slug     |                      j                      |          q          |                                                          o                                                          |          created_at           
----+-------------+---------------------------------------------+---------------------+---------------------------------------------------------------------------------------------------------------------+-------------------------------
  2 | 6Mm_RDQnBFC | {"foo": 42, "bar": "less interesting data"} | .foo                | [{"name": "slurp", "enabled": false}, {"name": "null-input", "enabled": false}, {"name": "compact-output", "enabled.| 2023-05-12 01:57:54.43762+00
    |             |                                             |                     |.": false}, {"name": "raw-input", "enabled": false}, {"name": "raw-output", "enabled": false}, {"name": "sort-keys",.| 
    |             |                                             |                     |. "enabled": false}]                                                                                                 | 
  3 | -HliBSll-7z | {"abc": 1, "abcd": 2, "Foo": 3}             | keys                | [{"name": "slurp", "enabled": false}, {"name": "null-input", "enabled": false}, {"name": "compact-output", "enabled.| 2023-05-12 02:14:45.195236+00
    |             |                                             |                     |.": false}, {"name": "raw-input", "enabled": false}, {"name": "raw-output", "enabled": false}, {"name": "sort-keys",.| 
    |             |                                             |                     |. "enabled": false}]                                                                                                 | 
  4 | VOpN1OUW76S | [1,5,3,0,7]                                 | map(select(. >= 2)) | [{"name": "slurp", "enabled": false}, {"name": "null-input", "enabled": false}, {"name": "compact-output", "enabled.| 2023-05-12 02:16:58.514398+00
    |             |                                             |                     |.": false}, {"name": "raw-input", "enabled": false}, {"name": "raw-output", "enabled": false}, {"name": "sort-keys",.| 
    |             |                                             |                     |. "enabled": false}]                                                                                                 | 
(3 rows)

jqplay-db=# SELECT * FROM snippets_id_seq;
 last_value | log_cnt | is_called 
------------+---------+-----------
          4 |      31 | t
(1 row)