Skip to content

Feature/admin forth/1259/add delete many to dataapi#502

Open
kulikp1 wants to merge 3 commits intonextfrom
feature/AdminForth/1259/add-delete-many-to-dataapi
Open

Feature/admin forth/1259/add delete many to dataapi#502
kulikp1 wants to merge 3 commits intonextfrom
feature/AdminForth/1259/add-delete-many-to-dataapi

Conversation

@kulikp1
Copy link
Collaborator

@kulikp1 kulikp1 commented Mar 12, 2026

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a deleteMany method to AdminForth's data API layer, enabling bulk deletion of records by primary key across all supported database connectors (SQLite, PostgreSQL, MySQL, MongoDB, ClickHouse).

Changes:

  • Added deleteMany method to all five data connectors (SQLite, PostgreSQL, MySQL, MongoDB, ClickHouse) and to the type interfaces (IAdminForthDataSourceConnectorBase, IOperationalResource).
  • Added a new adminforth-auto-remove plugin reference in the dev-demo Taskfile.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
adminforth/types/Back.ts Adds deleteMany to connector and operational resource interfaces
adminforth/dataConnectors/sqlite.ts Implements deleteMany using parameterized ? placeholders
adminforth/dataConnectors/postgres.ts Implements deleteMany using $N placeholders
adminforth/dataConnectors/mysql.ts Implements deleteMany using ? placeholders
adminforth/dataConnectors/mongo.ts Implements deleteMany using $in operator
adminforth/dataConnectors/clickhouse.ts Implements deleteMany with string-interpolated IDs
dev-demo/Taskfile.yaml Adds adminforth-auto-remove to the plugins list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a deleteMany method to the data API layer, enabling bulk deletion of records by primary key across all five database connectors (SQLite, PostgreSQL, MySQL, MongoDB, ClickHouse). It also registers a new adminforth-auto-remove plugin in the dev-demo task configuration.

Changes:

  • Added deleteMany implementations to all five data connectors (sqlite, postgres, mysql, mongo, clickhouse) for batch deletion by record IDs.
  • Declared deleteMany as an optional method on the IOperationalResource interface in Back.ts.
  • Added adminforth-auto-remove to the dev-demo plugin list.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
adminforth/types/Back.ts Added optional deleteMany to IOperationalResource interface
adminforth/dataConnectors/sqlite.ts New deleteMany using parameterized IN (?) query
adminforth/dataConnectors/postgres.ts New deleteMany using parameterized IN ($1, $2, ...) query
adminforth/dataConnectors/mysql.ts New deleteMany using parameterized IN (?) query
adminforth/dataConnectors/mongo.ts New deleteMany using $in operator
adminforth/dataConnectors/clickhouse.ts New deleteMany using ALTER TABLE ... DELETE WHERE with named params
dev-demo/Taskfile.yaml Added adminforth-auto-remove to plugins list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

query: `ALTER TABLE ${this.dbName}.${resource.table} DELETE WHERE ${conditions}`,
query_params: queryParams,
});
return recordIds.length ?? 0;
Comment on lines +1763 to +1764

deleteMany?(recordIds: any[]): Promise<number>;
Comment on lines +1763 to +1764

deleteMany?(recordIds: any[]): Promise<number>;
Comment on lines +385 to +390
async deleteMany({ resource, recordIds }: { resource: AdminForthResource, recordIds: any[] }): Promise<number> {
const placeholders = recordIds.map(() => '?').join(',');
const q = this.client.prepare(`DELETE FROM ${resource.table} WHERE ${this.getPrimaryKey(resource)} IN (${placeholders})`);
const res = await q.run(...recordIds);
return res.changes ?? 0;
}
Comment on lines +458 to +463
async deleteMany({ resource, recordIds }: { resource: AdminForthResource; recordIds: any[] }): Promise<number> {
const placeholders = recordIds.map((_, idx) => `$${idx + 1}`).join(', ');
const query = `DELETE FROM "${resource.table}" WHERE "${this.getPrimaryKey(resource)}" IN (${placeholders})`;
const res = await this.client.query(query, recordIds);
return res.rowCount ?? 0;
}
Comment on lines +423 to +428
async deleteMany({ resource, recordIds }: { resource: AdminForthResource; recordIds: any[] }): Promise<number> {
const placeholders = recordIds.map(() => '?').join(',');
const query = `DELETE FROM ${resource.table} WHERE ${this.getPrimaryKey(resource)} IN (${placeholders})`;
const [result] = await this.client.execute(query, recordIds);
return result.affectedRows ?? 0;
}
Comment on lines +400 to +404
async deleteMany({ resource, recordIds }: { resource: AdminForthResource; recordIds: any[] }): Promise<number> {
const collection = this.client.db().collection(resource.table);
const res = await collection.deleteMany({[this.getPrimaryKey(resource)]: { $in: recordIds }});
return res.deletedCount ?? 0;
}
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

Successfully merging this pull request may close these issues.

2 participants