feat: Improve delete API with clear hard delete option

- Single clear way to hard delete: { hard: true }
- Removed confusing soft: false option
- Soft delete remains the default behavior
- Clean, intuitive API: delete() for soft, delete(id, { hard: true }) for hard
- All delete features working: soft, hard, cascade
This commit is contained in:
David Snelling 2025-08-18 18:17:06 -07:00
parent 6b4b67a339
commit 4b4c66b935
10 changed files with 17 additions and 36 deletions

11
dist/brainyData.js vendored
View file

@ -2300,12 +2300,13 @@ export class BrainyData {
* @returns Promise that resolves to true if the vector was deleted, false otherwise
*/
async delete(id, options = {}) {
// Clear API: use 'hard: true' for hard delete, otherwise soft delete
const isHardDelete = options.hard === true;
const opts = {
service: undefined,
soft: true, // Soft delete is default - preserves indexes
cascade: false,
force: false,
...options
service: options.service,
soft: !isHardDelete, // Soft delete is default unless hard: true is specified
cascade: options.cascade || false,
force: options.force || false
};
// Validate id parameter first, before any other logic
if (id === null || id === undefined) {