Skip to main content
Solved

Cleaning up unused database records


nphilips

What is the best way to automate the periodic deletion of all records in a database that are not connected to a card? (The records are the children the parent cards in the connection)

Best answer by joao-quint

Great question — and a common use case for maintaining clean and efficient data structures in Pipefy!

If you want to periodically delete all database records that are not connected to any card (i.e., orphaned child records), here’s the best way to automate that.

Recommended Solution: Using Pipefy GraphQL API + Scheduler (Make, n8n, or custom script)

🧠 Why the API is necessary:

Pipefy does not offer a native automation to delete records or filter database items based on whether they're connected or not. But using the GraphQL API, you can:

  1. Fetch all records in a database.

  2. Check their connections (via connectedCardsCount or reverse lookups).

  3. Delete the ones that have no connections.

🛠️ Step-by-Step (Using Make.com or n8n.io)

1. Create a recurring trigger

  • Run every X days/hours using a scheduler module.

2. Query your database

Use the GraphQL query to list all database records and their connection counts:

{
  table_records(table_id: "your_table_id", first: 100) {
    edges {
      node {
        id
        title
        connected_cards_count
      }
    }
  }
}

If connected_cards_count == 0, it means the record is not linked to any card.

🔗 Alternatively, if you have a reverse connection set up from the parent pipe to the child records, you can also query through that connection field.

3. Filter the unconnected records

Use logic in your automation tool to filter only records with connected_cards_count === 0.

4. Delete unconnected records

Use the mutation:

mutation {
  deleteTableRecord(input: {id: "record_id"}) {
    success
  }
}

Loop through each orphaned record and delete it.

📚 API Docs: https://developers.pipefy.com/

🔒 Important Notes

  • Only users with permission to delete database records can use this API mutation.

  • Make sure you log or back up deletions if needed for auditability.

  • You might need pagination if your database has more than 100 records — handle pageInfo.hasNextPage.

✅ Bonus: Add a Manual "Clean Now" Trigger

You can also expose this as a webhook or manual button for staff to trigger cleanup when needed — without waiting for the next scheduled run.

 

View original
Did this topic help you find an answer to your question?

5 replies

joao-quint
Pipefy Staff
Forum|alt.badge.img+3
  • Pipefy Staff
  • 47 replies
  • Answer
  • July 1, 2025

Great question — and a common use case for maintaining clean and efficient data structures in Pipefy!

If you want to periodically delete all database records that are not connected to any card (i.e., orphaned child records), here’s the best way to automate that.

Recommended Solution: Using Pipefy GraphQL API + Scheduler (Make, n8n, or custom script)

🧠 Why the API is necessary:

Pipefy does not offer a native automation to delete records or filter database items based on whether they're connected or not. But using the GraphQL API, you can:

  1. Fetch all records in a database.

  2. Check their connections (via connectedCardsCount or reverse lookups).

  3. Delete the ones that have no connections.

🛠️ Step-by-Step (Using Make.com or n8n.io)

1. Create a recurring trigger

  • Run every X days/hours using a scheduler module.

2. Query your database

Use the GraphQL query to list all database records and their connection counts:

{
  table_records(table_id: "your_table_id", first: 100) {
    edges {
      node {
        id
        title
        connected_cards_count
      }
    }
  }
}

If connected_cards_count == 0, it means the record is not linked to any card.

🔗 Alternatively, if you have a reverse connection set up from the parent pipe to the child records, you can also query through that connection field.

3. Filter the unconnected records

Use logic in your automation tool to filter only records with connected_cards_count === 0.

4. Delete unconnected records

Use the mutation:

mutation {
  deleteTableRecord(input: {id: "record_id"}) {
    success
  }
}

Loop through each orphaned record and delete it.

📚 API Docs: https://developers.pipefy.com/

🔒 Important Notes

  • Only users with permission to delete database records can use this API mutation.

  • Make sure you log or back up deletions if needed for auditability.

  • You might need pagination if your database has more than 100 records — handle pageInfo.hasNextPage.

✅ Bonus: Add a Manual "Clean Now" Trigger

You can also expose this as a webhook or manual button for staff to trigger cleanup when needed — without waiting for the next scheduled run.

 


nphilips
  • Author
  • Explorer
  • 2 replies
  • July 6, 2025

Thank you for your quick reply!

 

In Step 2 of your suggested solution, I’m getting an error: “Field 'connected_cards_count' doesn't exist on type 'TableRecordWithCount'”.

 

Please advise.


joao-quint
Pipefy Staff
Forum|alt.badge.img+3
  • Pipefy Staff
  • 47 replies
  • July 14, 2025

In this one, you need to create a code to storage the amount of ids returned and put in a variable.


  • Explorer
  • 2 replies
  • July 19, 2025
nphilips wrote:

What is the best way to automate the periodic deletion of all records in a database that are not connected to a card check amdarklimited.com? (The records are the children the parent cards in the connection)

The best way is to set up an automated scheduled task that periodically deletes all child records not linked to a parent card. This can be done using your database's built-in scheduler or an external task scheduler like cron. The task should run a query that checks for and removes records without a valid connection to a card. This ensures your data stays clean without manual intervention.


nphilips
  • Author
  • Explorer
  • 2 replies
  • July 20, 2025

In case this helps anyone else:

My problem was how to check for records that aren’t connected to a parent card.

As of now, Pipefy’s graphql API doesn’t expose that information directly from the records.

To get this information, you have to work backwards - query for all the cards in the pipe and their child records, save a list of ‘child record’ IDs, and then delete all records in the database that aren’t in the list.

Query to get list of cards and their child records:

{ allCards(pipeId:"*********") { nodes { title child_relations { cards { title id } } } }}


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings