mirror of
https://github.com/Kong/insomnia.git
synced 2026-06-03 21:55:53 -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.
39 lines
1010 B
TypeScript
39 lines
1010 B
TypeScript
import type { RunnerTestResult } from 'insomnia-data';
|
|
import { database as db, models } from 'insomnia-data';
|
|
|
|
const { type } = models.runnerTestResult;
|
|
|
|
export function create(patch: Partial<RunnerTestResult> = {}) {
|
|
if (!patch.parentId) {
|
|
throw new Error('New RunnerTestResult missing `parentId` ' + JSON.stringify(patch));
|
|
}
|
|
|
|
return db.docCreate(type, patch);
|
|
}
|
|
|
|
export function update(testResult: RunnerTestResult, patch: Partial<RunnerTestResult>) {
|
|
return db.docUpdate(testResult, patch);
|
|
}
|
|
|
|
export function getByParentId(parentId: string) {
|
|
return db.findOne<RunnerTestResult>(type, { parentId });
|
|
}
|
|
|
|
export function getById(_id: string) {
|
|
return db.findOne<RunnerTestResult>(type, {
|
|
_id,
|
|
});
|
|
}
|
|
|
|
export function all() {
|
|
return db.find<RunnerTestResult>(type);
|
|
}
|
|
|
|
export function remove(item: RunnerTestResult) {
|
|
return db.remove<RunnerTestResult>(item);
|
|
}
|
|
|
|
export function findByParentId(parentId: string) {
|
|
return db.find<RunnerTestResult>(type, { parentId: parentId });
|
|
}
|