mirror of
https://github.com/Kong/insomnia.git
synced 2026-06-04 06:10:24 -04:00
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.
25 lines
727 B
TypeScript
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 });
|
|
}
|