import type { Class } from '@travetto/runtime'; import type { ModelType, OptionalId } from '../types/model.ts'; import type { ModelBasicSupport } from './basic.ts'; /** * Interface for simple CRUD * @concrete */ export interface ModelCrudSupport extends ModelBasicSupport { /** * Update an item * @param item The document to update. * @throws {NotFoundError} When an item is not found */ update(cls: Class, item: T): Promise; /** * Create or update an item * @param item The document to upsert * @param view The schema view to validate against */ upsert(cls: Class, item: OptionalId): Promise; /** * Update partial, respecting only top level keys. * * When invoking this method, any top level keys that are null/undefined are treated as removals/deletes. Any properties * that point to sub objects/arrays are treated as wholesale replacements. * * @param id The document identifier to update * @param item The document to partially update. * @param view The schema view to validate against * @throws {NotFoundError} When an item is not found */ updatePartial(cls: Class, item: Partial & { id: string }, view?: string): Promise; /** * List all items */ list(cls: Class): AsyncIterable; }