Files
insomnia/packages/insomnia-data/node-src/services/project-lint-ruleset.ts
Bingbing b09cde814d refactor: extract insomnia-data into workspace package (#10010)
Move insomnia-data models, services, database code, and common utilities into a dedicated workspace package. Update consumers to import from the new package entrypoints and declare workspace dependencies for the extracted package.
2026-06-02 09:49:10 +00:00

25 lines
727 B
TypeScript

import type { ProjectLintRuleset } from 'insomnia-data';
import { database as db, models } from 'insomnia-data';
const { type } = models.projectLintRuleset;
export function getByParentId(projectId: string) {
return db.findOne<ProjectLintRuleset>(type, { parentId: projectId });
}
export async function upsert(projectId: string, patch: Partial<ProjectLintRuleset> = {}) {
const existing = await db.findOne<ProjectLintRuleset>(type, {
parentId: projectId,
});
if (!existing) {
return db.docCreate<ProjectLintRuleset>(type, { ...patch, parentId: projectId });
}
return db.docUpdate(existing, patch);
}
export function remove(projectId: string) {
return db.removeWhere(type, { parentId: projectId });
}