Deleting table with 'Links' [May 26]

:raising_hand_man: AK asked

I’m trying to empty table with rest api. But it seems like because it have relation column to other table I can’t(?).

api end-point:

https://site/api/v1/db/data/bulk/noco/barks/games_log/all

request body:

```JSON

{

“שם המשחק”: “null”,

“שם הנער”: “null”,

“פיקדון”: “null”,

“נלקח בשעה”: “null”,

“הוחזר בשעה”: “null”

}

```

(all the columns)

response:

```JSON

{

“msg”: “delete from "nc_ry8c__games" - update or delete on table "nc_ry8c__games" violates foreign key constraint "nc_ry8c__teen_nc_ry8c__games_id_foreign" on table "nc_ry8c__teen"”

}

```

(code 400 Error: Bad Request)

What can I do for successfully empty the table? This is the last thing to do before I’m finishing my system🙏

:man_bald: dstala replied

You will be required to delete ‘Link to another record’ column (relational column) before deleting the table.

:raising_hand_man: AK replied

I want to delete the table’s rows (empty it from data), not delete all the table. Maybe I’m using the wrong endpoint?

:person_tipping_hand: o1lab replied

you would have to delete the related rows to begin with then delete these rows

:person_tipping_hand: o1lab replied

or you would have to set cascade on delete option while creating link to another record

:raising_hand_man: AK replied

I re-create with cascade but it’s until not working. I also tried to delete all the rows in all the tables in case because it created and related to the table before it will make me problem, but until the same error…

:raising_hand_man: AK replied

Any suggestions? :pray:

:raising_hand_man: AK replied

I’m still looking for solution :pray:

Can it be bug or It something I’m doing worng?

:man_bald: dstala replied

<@396976051172933635>, share your project information please (copy project info from : menu on right top).

:raising_hand_man: AK replied

Node: v12.22.12

Arch: x64

Platform: linux

Docker: false

Database: pg

ProjectOnRootDB: true

RootDB: pg

PackageVersion: 0.90.11

:raising_hand_man: AK replied

<@857998597474484295>

:man_bald: dstala replied

<@396976051172933635>, apologies for delayed response.

on PG, I was able to clear records with ‘CASCADE’ on delete option set during LinkToAnotherRecord creation.

```

await api.dbTableColumn.create(tblCity.id, {

title: “countryRead”,

uidt: UITypes.LinkToAnotherRecord,

parentId: tblCity.id,

childId: tblCountry.id,

type: ‘mm’,

onDelete: ‘CASCADE’

});

await api.dbTableRow.bulkCreate(“nc”, project.id, tblCity.id, [{Title: “a1”}, {Title: “a2”}, {Title: “a3”}, {Title: “a4”}])

await api.dbTableRow.bulkCreate(“nc”, project.id, tblCountry.id, [{Title: “b1”}, {Title: “b2”}, {Title: “b3”}, {Title: “b4”}])

for (let i=1; i<=4; i++)

await api.dbTableRow.nestedAdd(“nc”, project.id, tblCity.id, ${i}, “mm”, “countryRead”, ${i});

await api.dbTableRow.bulkDeleteAll(“nc”, project.id, tblCity.id, [“1”, “2”, “3”, “4”])

await api.dbTableRow.bulkDeleteAll(“nc”, project.id, tblCountry.id, [“1”, “2”, “3”, “4”])

```

:raising_hand_man: AK replied

I will try to re create it from code with the sdk and update if now it is working.

Autogenerated from discord


Join NocoDB’s community

DiscordTwitterRedditDocs