import { RelationService } from "./RelationService"; import { RelationWriteService } from "./RelationWriteService"; import { FetchService } from "./FetchService"; import { DrizzleClient } from "../interfaces"; import { PostgresCollectionRegistry } from "../collections/PostgresCollectionRegistry"; /** * Service for handling all row write operations. * Handles saving, deleting, and updating rows. */ export declare class PersistService { private db; private registry; /** Reads: whether a row is under a parent, the key a link joins on. */ private relationService; /** Writes: junction membership, foreign-key stamping, links. */ private relationWrites; private fetchService; constructor(db: DrizzleClient, registry: PostgresCollectionRegistry); /** * Explain a row write that matched nothing — see {@link explainZeroRowWrite} * for why a zero-row write cannot be reported as success. */ private explainZeroRowWrite; /** * Delete an row by ID */ delete(collectionPath: string, id: string | number, _databaseId?: string): Promise; /** * Delete all rows from a collection */ deleteAll(collectionPath: string, _databaseId?: string): Promise; /** * The field on the *target* row that records the parent, for a create under * a nested one-to-many path. * * A **field**, not the column: the value is stamped into the caller's * payload, which is keyed by wire names — `authorId`, never the `author_id` * the relation names its link by. Stamping the column instead put a key on * the payload that no property answers to, and `strictWrites` rejected the * request the framework had just written to. * * Returns `undefined` when the link is not a column at all (a multi-hop * `joinPath`), so the caller writes the row without stamping anything. * * `relation.localKey` is deliberately not consulted: it names a column on * the *source* table. Falling back to it here — which is what this used to * do, and first — stamped the parent's own foreign key onto the child row. */ private resolveParentForeignKeyColumn; /** * Save an row (create or update) * * With `options.upsert`, the row is written with INSERT ... ON CONFLICT DO * UPDATE against the primary key rather than a plain UPDATE. That is one * statement, so it cannot lose a race the way a read-then-write can, and it * does not care whether the row already exists — which is what a re-runnable * import needs. */ save>(collectionPath: string, values: Partial, id?: string | number, databaseId?: string, options?: { upsert?: boolean; }): Promise>; /** * Get the RelationService instance for external use */ getRelationService(): RelationService; /** * The write half, for external use. Separate from * {@link getRelationService} because they are separate objects now: reads * answer questions, writes change rows, and the callers of one are not the * callers of the other. */ getRelationWriteService(): RelationWriteService; /** * Get the FetchService instance for external use */ getFetchService(): FetchService; /** * Translate raw PostgreSQL / Drizzle errors into user-friendly messages. */ private toUserFriendlyError; }