Solved

Clear several Database records at once

  • 23 August 2020
  • 5 replies
  • 338 views

Userlevel 4

Hi People, 

We need to clear 2000 register of a database?, how i can do fast?

 

thanks

icon

Best answer by Nicole Chiroli 26 August 2020, 14:26

View original

5 replies

Userlevel 7
Badge +10

Hello @gonzalo9, how are you doing today?

You can use our API to delete them. 
 

mutation{

a1: deleteTableRecord(input:{Id:xxxxx}){success}
a2: deleteTableRecord(input:{Id:xxxxx}){success}
}

and so on. 

The ID:xxxx would be the IDs of the records you wish to delete. We recommend you delete, tops, 150 at a time. I hope it helps! :) 

Userlevel 4

Thanks, how i can view for all records the IDs?

Userlevel 7
Badge +10

Hey, @gonzalo9. Good morning :)

You can find them through the API as well like this:
{
  table_records(first: 30, table_id: "s5UuWo_N") {
    edges {
      node {
        id
        title
        }
    }
    pageInfo {
      endCursor
      hasNextPage
      hasPreviousPage
      startCursor
    }
  }
}

It is important to stress that, if you are going to check it through API, we have pagination so you can see all cards within the phase. The current limit of cards/records shown is 30 cards per phase and 50 cards per pipe/db.


Pagination works like this; you will set the pageInfo attribute and it will return the "endcursor", with the endcursor you can see the other cards within that phase, putting it as an argument in the "after" command.


Example:{
  phase(id: 6158453) {
    name
    cards (first:30 after: "WzQzODY0NDcwXQ==") {
      pageInfo{
        endCursor
        hasNextPage
      }
      edges {
        node {
          fields{
            value
            field{
              id
              label
            }
          }
          id
          title
          createdAt
          done


          pipe {
            id
            name
          }
          creatorEmail
          current_phase {
            id
            name
          }
        }
      }
    }
  }
}

 

You can also create an ID field and check from inside the database:
 


Hope it helps :)!

Userlevel 7
Badge +9

@Janaina_Barreto

Look at this tip about deleting records in a database.

Userlevel 2

Just a small comment/correction, I had to use “id” (all lowercase) instead of “Id” - otherwise it will fail with “Argument 'id' on InputObject 'DeleteTableRecordInput' is required. Expected type ID!".

#this will FAIL on the Id as it requires "id" in lowercase
mutation{

a1: deleteTableRecord(input:{Id:xxxxx}){success}
a2: deleteTableRecord(input:{Id:xxxxx}){success}
}
#this works as it uses lowercase id
mutation {
D2: deleteTableRecord(input: {id: 499677723}) {
success
}
}

 

Reply